home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / windowsxp / winbolo / winbolo109a-setup.exe / Standard Autopilot.c next >
C/C++ Source or Header  |  1995-05-13  |  70KB  |  1,517 lines

  1. // ****************************************************************************
  2. //
  3. // Bolo standard Autopilot Brain
  4. // (C) 1993-1995 Stuart Cheshire <cheshire@cs.stanford.edu>
  5. // I make no claims that this is good code. It is provided solely as
  6. // simple example code to assist in writing Bolo plug-in Brain modules.
  7. // I do not have the time to tidy it up and make it elegant at all.
  8. // It's poorly structured and it uses far too many global variables.
  9. //
  10. // Version history:
  11. // 0.9 12th May 1995. Updated to new version 3 Brain interface.
  12. //     Made it prefer building slightly ahead, rather than under the tank,
  13. //     when moving at a reasonable speed (speeds >= forest speed)
  14. // 0.8 22nd Nove 1993. Added "Do Building" menu option, and moved
  15. //     decide_building(nearx, neary) call to inside "if (correction╔" statement
  16. // 0.7 6th Nov 1993. Converted to A-Star heuristic, added route algorithm
  17. //     debugging window and made tanks seek out boats for transportation.
  18. //     Record time for Everard Island 18 min 30 secs
  19. // 0.6 19th Oct 1993. Made it not try to pick up pillboxes which are sitting in deep sea.
  20. // 0.5 13th Oct 1993. Major improvements to route finding and decision making. Pillbox
  21. //     firing areas used, clear path routines, revised progress/boredom routines.
  22. // 0.4 7th Oct 1993. Route finding switched to multi-parameter decision.
  23. // 0.3 1st Oct 1993. New menu options, including "assassin" mode.
  24. // 0.2 26th May 1993. Released with Bolo 0.99.
  25. // 0.1 21st Feb 1993. Built into Bolo 0.98 as "Autopilot"
  26.  
  27. #define AUTO_DEBUG 0
  28.  
  29. // ****************************************************************************
  30.  
  31. // Define an integer square root routine
  32. #include <FixMath.h>
  33. #define sqrt(X) (FracSqrt(X) >> 15)
  34.  
  35. // ****************************************************************************
  36.  
  37. #include "vsprintf.h"
  38. #include "Brain.h"
  39.  
  40. // ****************************************************************************
  41.  
  42. #define abs(X) (((X) < 0 ) ? -(X) : (X))
  43. #define max(X,Y) ((X) > (Y) ? (X) : (Y))
  44. #define min(X,Y) ((X) < (Y) ? (X) : (Y))
  45.  
  46. // pillpickup_x and y are used to record the location of the last
  47. // pillbox picked up in case it turns out to be fatal deep sea underneath
  48.  
  49. local const BrainInfo *info;
  50. local long TimeNow;
  51. local MAP_X nearx, pillpickup_x, fatal_x;
  52. local MAP_Y neary, pillpickup_y, fatal_y;
  53. local MAP_X tankleftx, tankrightx;
  54. local MAP_Y tanktopy, tankbottomy;
  55. local Boolean tank_close_to_mine;
  56. local Boolean still_on_boat;    // Set until tank gets off boat
  57. local BYTE land_direction;        // Initial guess at where the land is
  58.  
  59. // If cannot reach a target, get bored and ignore it after 20 seconds
  60. #define ATTENTION_SPAN (60*20)
  61. #define MAX_VIS_RANGE 0x7FFF
  62. #define DEFENSIVE_RANGE 0xA00
  63.  
  64. typedef struct
  65.     {
  66.     u_long remaining_progress;    // Current 'best' point so far
  67.     long last_progress;            // Last time progress was made
  68.     long ignore_until;            // when we are bored with something
  69.     } ProgressInfo;
  70. #define MAX_PROGRESS 0xFFFFFFFF
  71. local long boredomtime = ATTENTION_SPAN;
  72. local ProgressInfo *tankprogress, *pillprogress, *baseprogress;
  73. local ProgressInfo scoutingprogress, manrescueprogress;
  74. //local u_long previous_closest_dist = MAX_VIS_RANGE;
  75. //local long current_attempt_time;
  76.  
  77. // Can place pillbox on swamp, crater, road, rubble and grass
  78. static Boolean can_build_pillbox[NUM_TERRAINS] = { 0,0,1,1, 1,0,1,1, 0,0,0,0, 0,0 };
  79.  
  80. // Keyboard Control variables
  81. local u_long keys, taps, last_keys, last_taps;
  82.  
  83. // Menu handling variables and mode settings
  84. #define MyMenuID 1000
  85. local MenuHandle MyMenu;
  86. local WindowPtr debugwindow, routewindow;
  87.  
  88. local Boolean do_explain   = AUTO_DEBUG;
  89. local Boolean do_showroute = AUTO_DEBUG;
  90.  
  91. enum
  92.     {
  93.     m_about = 1,
  94.     m_sep1, m_default, m_assassin, m_pillhunter, m_basehunter, m_defensive,
  95.     m_sep2, m_explore, m_laymines, m_clearmines, m_dobuilding,
  96.     m_attacktanks, m_attackpills, m_attackbases, m_repairpills, m_placepills, m_ppoffensive,
  97.     m_sep3, m_explain, m_route
  98.     };
  99.  
  100. typedef struct
  101.     {
  102.     Boolean explore, laymines, clearmines, dobuilding;
  103.     Boolean attacktanks, attackpills, attackbases, repairpills, placepills, ppoffensive;
  104.     } SETTINGS;
  105.  
  106. // Flags are:                         ex lm cm db at ap cb rp pp po
  107. local const SETTINGS s_default    = { 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 };
  108. local const SETTINGS s_assassin   = { 1, 0, 1, 1, 1, 0, 0, 1, 1, 1 };
  109. local const SETTINGS s_defensive  = { 0, 0, 1, 1, 1, 1, 0, 1, 1, 0 };
  110. local const SETTINGS s_pillhunter = { 1, 0, 1, 1, 0, 1, 0, 1, 1, 0 };
  111. local const SETTINGS s_basehunter = { 1, 0, 1, 1, 0, 0, 1, 1, 1, 0 };
  112. local SETTINGS s;
  113.  
  114. // Thinking variables
  115. local Boolean shootit, shootsoon, runaway;
  116. #define SHOOT_NOTHING 0xFFFF
  117. local OBJECT shootwhat;
  118. local Boolean *shoot_path_costs;
  119. local BYTE chosen_gunrange;        // Desired gun range, for shooting mines
  120. local BYTE shoot_direction;        // to aim the gun accurately
  121. local BYTE shoot_dir_vote;        // shoot_direction converted to range 0-15
  122. local BYTE chosen_direction;
  123. local BYTE flying_shells;        // total number of shells in flight at the moment
  124. local BYTE incoming_shells;        // total number of shells heading towards us
  125. local long direction_votes[16];
  126. local u_long target_distances[16];
  127. local BYTE direction_maxspeeds[16];
  128.  
  129. local MAP_X scoutx;
  130. local MAP_Y scouty;
  131. #define CAN_DO_BUILDING (info->build->action == 0 && info->man_status == 0 && \
  132.                         !info->inboat && flying_shells == 0)
  133. #define CAN_BUILD_PILLBOX (CAN_DO_BUILDING && \
  134.                         s.placepills && info->carriedpills && info->trees >= 4)
  135.  
  136. typedef struct { char x; char y; } charpair;
  137.  
  138. typedef union
  139.     {
  140.     charpair s25[25];
  141.     struct { charpair s1[1]; charpair s8[8]; charpair s16[16]; } s;
  142.     } SURROUNDING_SQUARES;
  143.  
  144. local const SURROUNDING_SQUARES surrounding =
  145.     {
  146.     0,0,
  147.     0,-1, 1,-1, 1,0, 1,1, 0,1, -1,1, -1,0, -1,-1,
  148.     0,-2, 1,-2, 2,-2, 2,-1, 2,0, 2,1, 2,2, 1,2,
  149.     0,2, -1,2, -2,2, -2,1, -2,0, -2,-1, -2,-2, -1, -2
  150.     };
  151.  
  152. // ****************************************************************************
  153.  
  154. // Debugging message routines
  155.  
  156. #define EXPLAIN_WITH_MESSAGES 0
  157.  
  158. local void sendmessage(u_char *msg)
  159.     {
  160.     int i;    // Setting player bits to all zero makes this a debugger message
  161.     for (i=0; i<(info->max_players+31)/32; i++) info->messagedest[i] = 0;
  162.     for (i=0; i<=msg[0]; i++) info->sendmessage[i] = msg[i];
  163.     }
  164.  
  165. local void debug(char *format, ...)
  166.     {
  167.     unsigned char buffer[256];
  168.     va_list ptr;
  169.     va_start(ptr,format);
  170.     buffer[0] = vsprintf((char *)buffer+1, format, ptr);
  171.     va_end(ptr);
  172.     DebugStr(buffer);
  173.     }
  174.  
  175. local Boolean SameString(const unsigned char *a, const unsigned char *b)
  176.     {
  177.     int i;
  178.     for (i=0; i<=a[0]; i++) if (a[i] != b[i]) return(FALSE);
  179.     return(TRUE);
  180.     }
  181.  
  182. local void explain(char *format, ...)
  183.     {
  184.     if (do_explain)
  185.         {
  186.         static unsigned char old_buffer[256];
  187.         unsigned char buffer[256];
  188.         va_list ptr;
  189.         va_start(ptr,format);
  190.         buffer[0] = vsprintf((char *)buffer+1, format, ptr);
  191.         va_end(ptr);
  192.         
  193. #if EXPLAIN_WITH_MESSAGES
  194.         if (info->sendmessage[0] == 0 && !SameString(buffer, old_buffer))
  195.             { sendmessage(buffer); BlockMove(buffer, old_buffer, 1+buffer[0]); }
  196. #else
  197.         if (!SameString(buffer, old_buffer))
  198.             {
  199.             GrafPtr old;
  200.             RgnHandle updateRgn = NewRgn();
  201.             GetPort(&old);
  202.             SetPort(debugwindow);
  203.             TextFont(geneva);
  204.             TextSize(10);
  205.             ScrollRect(&debugwindow->portRect, 0, -12, updateRgn);
  206.             DisposeRgn(updateRgn);
  207.             MoveTo(debugwindow->portRect.left + 6, debugwindow->portRect.bottom - 6);
  208.             DrawString(buffer);
  209.             SetPort(old);
  210.             BlockMove(buffer, old_buffer, 1+buffer[0]);
  211.             }
  212. #endif
  213.         }
  214.     }
  215.  
  216. // ****************************************************************************
  217.  
  218. // General utility routines
  219.  
  220. local TERRAIN raw_getmapcell(MAP_X x, MAP_Y y)
  221.     {
  222.     // This was the old way, when Brains were just given a small square of the map
  223. /*    if (x < info->view_left || y < info->view_top) return(DEEPSEA);*/
  224. /*    y -= info->view_top;*/
  225. /*    x -= info->view_left;*/
  226. /*    if (x >= info->view_width || y >= info->view_height) return(DEEPSEA);*/
  227. /*    return(info->viewdata[y*info->view_width + x]);*/
  228.  
  229.     // This is the new way, now that Brains get a pointer to the whole world
  230.     return(info->theWorld[(u_short)y << 8 | x]);
  231.     }
  232.  
  233. // These two read the terrain / check for mine at MAP coordinates X,Y
  234. #define getmapcellM(X,Y) (raw_getmapcell((X),(Y)) & TERRAIN_MASK)
  235. #define checkmineM(X,Y)  (raw_getmapcell((X),(Y)) & TERRAIN_MINE)
  236.  
  237. // These two read the terrain / check for mine at WORLD coordinates X,Y
  238. #define getmapcellW(X,Y) getmapcellM((X)>>8, (Y)>>8)
  239. #define checkmineW(X,Y)  checkmineM((X)>>8, (Y)>>8)
  240.  
  241. local u_long findrange(WORLD_X x1, WORLD_Y y1, WORLD_X x2, WORLD_Y y2)
  242.     {
  243.     register long xdiff = (long)x1 - (long)x2;
  244.     register long ydiff = (long)y1 - (long)y2;
  245.     return(sqrt(xdiff*xdiff + ydiff*ydiff));
  246.     }
  247.  
  248. #define objectrange_to_me(OB) findrange((OB)->x, (OB)->y, info->tankx, info->tanky)
  249.  
  250. // For Mac fixed point trig routines, full circle is 2 * PI * 0x10000
  251. // We want full circle to be 0x100, so divide by (2 * PI * 0x10000 / 0x100)
  252. // which is 1608 in decimal
  253. #define aim(X,Y) ((FixATan2(-(Y),(X))/1608) & 0xFF)
  254.  
  255. // sin and cos routines are adjusted to take angles in the range 0-255
  256. // and return return values in the range +/-128
  257. #define sin(X) ((short)(FracSin((u_char)(X)*1608L) >> 23))
  258. #define cos(X) ((short)(FracCos((u_char)(X)*1608L) >> 23))
  259.  
  260. local ObjectInfo *find_object(OBJECT obtype, MAP_X x, MAP_Y y)
  261.     {
  262.     ObjectInfo *ob;
  263.     WORLD_X wx = (WORLD_X)x << 8;
  264.     WORLD_Y wy = (WORLD_Y)y << 8;
  265.     for (ob=&info->objects[0]; ob<&info->objects[info->num_objects]; ob++)
  266.         if (ob->object == obtype && ob->x == wx && ob->y == wy) return(ob);
  267.     return(NULL);
  268.     }
  269.  
  270. // ****************************************************************************
  271.  
  272. // Shots can't pass through buildings, half buildings or pillboxes
  273. // If we are chasing tank, also discourage wasting shots shooting forest
  274. // Men cannot run through buildings, half buildings, pillboxes, refbases or water/deepsea
  275. local BYTE stationary_target_path[NUM_TERRAINS] = { 5,  0,  0,  0,  0,  1,  0,  0,  4,  0,  0,  0, 16, 99 };
  276. local BYTE moving_target_path    [NUM_TERRAINS] = { 5,  0,  0,  0,  0,  4,  0,  0,  4,  0,  0,  0, 16, 99 };
  277. local BYTE running_man_path      [NUM_TERRAINS] = { 99, 99, 4,  4,  1,  2,  4,  1, 99,  1, 99, 99, 99, 99 };
  278.  
  279. // returns zero if there is a clear straight line path, from x,y, across terrain
  280. // specified by terraincosts, to the target at tx,ty, in at most maxsteps steps
  281. // (a step is half a map square)
  282. // If there is not a clear path, then it returns the cost,
  283. // measured in shots for shooting paths, and in time for man paths
  284. local short path_cost(WORLD_X x, WORLD_Y y, Boolean *terraincosts,
  285.     WORLD_X tx, WORLD_Y ty, WORD maxsteps)
  286.     {
  287.     BYTE direction = aim(tx - (long)x, ty - (long)y);
  288.     MAP_X lastx = 0, targx = tx>>8;
  289.     MAP_Y lasty = 0, targy = ty>>8;
  290.     short steps = findrange(tx, ty, x, y) >> 7;    // count in half-square steps
  291.     //short closest_step = 0;
  292.     short cost = 0;
  293.     if (steps > maxsteps) return(0x7FFF);
  294.  
  295.     // This first step is to make sure we skip over the initial square,
  296.     // and don't count a cost for it
  297.     x += sin(direction);
  298.     y -= cos(direction);
  299.  
  300.     while (--steps > 0)
  301.         {
  302.         x += sin(direction);
  303.         y -= cos(direction);
  304.         if ((x>>8)==targx && (y>>8)==targy) break;        // OK, reached target
  305.         if ((x>>8)==lastx && (y>>8)==lasty) continue;    // same square as last time -- skip it
  306.         cost += terraincosts[getmapcellW(x,y)];
  307.         }
  308.     return(cost);
  309.     }
  310.  
  311. // Man will not run over more than 5 squares of rubble, or 20 squares of road
  312. #define MAN_PATH(X,Y) (path_cost(info->tankx,info->tanky,running_man_path,(X),(Y),0x7FFF) < 20)
  313.  
  314. // Note, must assume shots CAN travel over unknown terrain, otherwise,
  315. // as soon as we leave the vicinity of an unsafe base, its terrain becomes
  316. // unknown, and we would immediately return, assuming it safe 
  317. local Boolean safe_base(ObjectInfo *base)
  318.     {
  319.     ObjectInfo *ob;
  320.     for (ob=&info->objects[0]; ob<&info->objects[info->num_objects]; ob++)
  321.         if (ob->object == OBJECT_PILLBOX && ob->pillbox_strength > 0 && (ob->info & OBJECT_HOSTILE))
  322.             if (path_cost(ob->x, ob->y, stationary_target_path, base->x, base->y, 16) == 0)
  323.                 return(FALSE);
  324.     return(TRUE);
  325.     }
  326.  
  327. // ****************************************************************************
  328.  
  329. // Route finding routines
  330.  
  331. #define ARMOUR_UNIT_COST 8    // The armour cost scale counts eighths of a unit of tank armour
  332. #define MAX_TIME_COST   0xFFFF
  333. #define MAX_SHELL_COST  0xFF
  334. #define MAX_ARMOUR_COST 0xFF
  335. #define UNKNOWN_COST    0xFFFF
  336. #define MAX_COST (UNKNOWN_COST-1)
  337.  
  338. // Notes:
  339. // The 'squarecost' array holds the costs to reach the target from the given square --
  340. // it forms a field for the tank to follow the steepest gradient downhill to its target.
  341. // The 'cost' values in the CostPoints are this cost to reach the destination, PLUS
  342. // a (mostly) conservative heuristic estimating the minimum cost for the tank to get
  343. // to this square from its current position. This heuristic helps guide the search
  344. // preferentially towards where the tank is now, rather then in fruitless directions
  345. // away from it.
  346.  
  347. typedef struct            // Used to find best route through cost array
  348.     {
  349.     u_char x;            // Location in array (NOT in MAP coordinates)
  350.     u_char y;
  351.     u_short time;        // Time to reach destination from this square
  352.     u_char shells;        // Shells required to reach destination from this square
  353.     u_char armour;        // Armour required to reach destination from this square (scaled)
  354.     u_char trees;
  355.     u_char spare;
  356.     u_char water;        // number of squares to be spent crossing water
  357.     u_char deepsea;        // set if path will cross deep sea
  358.     u_short cost;        // Overall 'cost' estimate to reach destination via this square
  359.     } CostPoint;
  360.  
  361. #define COST_SEARCH_RANGE 14
  362. // Tank can see the square it is on, and up to COST_SEARCH_RANGE
  363. // above, below and to either side of it
  364.  
  365. #define COST_ARRAY_SIZE (COST_SEARCH_RANGE + 1 + COST_SEARCH_RANGE)
  366. #define IN_COSTARRAY(X) ((BYTE)(X) < (BYTE)(COST_ARRAY_SIZE))
  367.  
  368. typedef u_char     u_char32   [32];                // Row of 32 unsigned char values
  369. typedef u_short    u_short32  [32];                // Row of 32 unsigned short values
  370.  
  371. local u_char32  pillcoverage[COST_ARRAY_SIZE];    // Array of rows of pillbox fire coverage
  372. local u_short32 squarecost  [COST_ARRAY_SIZE];    // Array of rows of cost values
  373. local u_short32 CPCost      [COST_ARRAY_SIZE];
  374.  
  375. local long costarray_time;        // time array was created
  376. // position of array on map, position of target on map, and
  377. // subtarget (target, or closest point if target is outside costarray)
  378. local MAP_X costarray_left, costtarget_x, subtarget_x;
  379. local MAP_Y costarray_top,  costtarget_y, subtarget_y;
  380. local BYTE costarray_boat;        // Whether costarray calculated for boat or tank
  381. local OBJECT costarray_targ;
  382. local u_char costarray_tankhits;
  383. // How many pillbox hits the tank's current position scores. Normally a two-hit square
  384. // is bad news, but if we are already sitting on a three-hit square, then two suddenly
  385. // looks quite desirable
  386. local BYTE ca_tankx, ca_tanky;    // Position of tank in costarray coordinates
  387.  
  388. #define MAX_HEAP_SIZE 200
  389. local CostPoint cost_heap[MAX_HEAP_SIZE];    // Sorted heap of CostPoints
  390. local short heap_size=0;
  391.  
  392. local void showroute(CostPoint c, u_short colour, u_short shotpoint)
  393.     {
  394.     RGBColor col = { 0, 0, 0 };
  395.     Rect r;
  396.     u_short lowbits = (colour & 0x7F) * 0x180 + 0x4000;
  397.     if (colour + 0x80 & 0x080) col.red   = lowbits;
  398.     if (colour + 0x80 & 0x100) col.green = lowbits;
  399.     if (colour + 0x80 & 0x200) col.blue  = lowbits;
  400.     RGBForeColor(&col);
  401.     r.top    = c.y * 8;
  402.     r.left   = c.x * 8;
  403.     r.bottom = r.top  + 8;
  404.     r.right  = r.left + 8;
  405.     if (shotpoint) InsetRect(&r, 1, 1);
  406.     PaintRect(&r);
  407.     //debug("%d,%d Cost %X Realcost %X", c.x, c.y, c.cost, colour);
  408.     }
  409.  
  410. local void addtoheap(int place, CostPoint new)
  411.     {
  412.     int parent = (place-1)>>1;
  413.     cost_heap[place]=new;
  414.     while (place>0 && cost_heap[parent].cost > cost_heap[place].cost)
  415.         {
  416.         CostPoint temp    = cost_heap[place ];
  417.         cost_heap[place ] = cost_heap[parent];
  418.         cost_heap[parent] = temp;
  419.         place=parent;
  420.         parent=(place-1)>>1;
  421.         }
  422.     }
  423.  
  424. local CostPoint removefromheap(void)
  425.     {
  426.     CostPoint top = cost_heap[0];            // extract top element
  427.     int gap   = 0;                            // top is now empty
  428.     int left  = 1;                            // Left child is element 1
  429.     int right = 2;                            // Right child is element 2
  430.     heap_size--;                            // We have removed one element
  431.     while(left<=heap_size)                    // move gap to bottom
  432.         {
  433.         if(right>heap_size || cost_heap[right].cost > cost_heap[left].cost)
  434.             { cost_heap[gap]=cost_heap[left ]; gap=left;  }
  435.         else{ cost_heap[gap]=cost_heap[right]; gap=right; }
  436.         left  = (gap<<1)+1;
  437.         right = (gap<<1)+2;
  438.         }
  439.     if(gap != heap_size) addtoheap(gap,cost_heap[heap_size]);
  440.     return(top);                            // return extracted element
  441.     }
  442.  
  443. // Note: the cost in the CostPoint is biased with the search heuristic
  444. // realcost is the actual cost to reach the destination from this point
  445. local void setcost(CostPoint c, u_short realcost)
  446.     {
  447.     int i;
  448.     Boolean already_present = (CPCost[    r.gs, nt = ntx]E)(_COST-1)
  449.  
  450. turn(    r.gs, nt = ntx]E.y * 8;// Ovt cost  [COST nt = ntx]E=st)
  451.     {
  452. / This fiIfeap(as usps)  reac(s 1608by MAX_Hf tankrun thr sittingbess  (CPChis fibecauseis not a cless  -exihots scost_heT (UNKNO)wo sudount abse,
  453. his fipun deep p, atarget  Cost(less u_sh--p p,run thrl terlbohe ta)colour + cost_==eT (UNKNO)wextrac/ This fiIfeasittings  (CPC, pick upst rourn re = cosget  2
  454.     heai pillboxCostPoi Coscolour _present = (CPC cost0; i<=a[0]; ze]);
  455.     rif (a[ (path_coap[heap_sii]. && o;
  456.     _heap[parent]i].y&& o;yreturn({eap(int placr););wextrac/ } This fiIfe Costasittingrcle nuk
  457. // pi  2
  458.     heaint)uldnt ahappsuddootPoten)colour ze || cost>=AP_SIZE 200
  459. l) ze--;                            colap(int plaze--;                ++r););
  460. local CostPoi realcoststPo_ost  [    // t
  461. locaRRAINS] = { 99, int i;1, 1, 08 08 s fiG && \
  462. , RIVER, SWAMPoinRAS] i;1, 03 08 02 s fiROAD, FOREST, RUBBLE, GRASSand  99,, 0 };
  463. s fiHALFG && \
  464. , BOAT, );*/
  465. /, REFBASE_Ti;1,divi1,diturn  && ob-_T, _MINE)
  466. _COST-1
  467. // ******* codt(X) ( is onnint cost_hea.ost' cost_er decisisemoved sittingbeepecifieeede COST_SEint
  468. localh--pt in positioroot roug_pro spent coute . void explain(codt(Xint c, u_sho    if (do_explARRAY(X) ((BY;
  469. )    _heARRAY(X) ((BY;y)
  470.         CostPoi// explore, odt(get_pankroot rour &. && o;, ca_ta    _hea.y&& o;;    // Pof ((x>, MAP_Y_heap[0eft, costt    if&.  ((x>, MAY y_heap[0eft, c8;
  471.     r.a.ysignedindrandY_he(((X, ty - -, ty -pillp)signedindrandy_he(((X, ty -y-, ty -pilly)signedindrancpolour)ic helps g=Y) ((dx,dy)    r.) ((dx,dy)    / 
  472.     if( raw_getmapE=stapcell((X),(Y)
  473.         }
  474.     if( raw_get.x * 8mapEIN_MASK)
  475. #def
  476.     if(ime;        /ankr= 0)
  477. #sendmess    // Sh    if(ime;        /ankcost sc#sendmescost sc*_UNIT_COST 8    // Th    if(ime;        e tan E.y * 8erage[COST_ARnt = ntx]h    if(ndran    {
  478.     // tCOST_A* 8;ray w+ststPo_ost  [    // t
  479. locaRcost_heime;        {
  480.     s    // COST_A 8;s    // Sh    if(ime;        {
  481.     cost s0;
  482.     ifc.        // Ar    if(ndran{
  483. 0;
  484.     if (sten alreadyeight_0;
  485.     if
  486.     }#if EXP     armour the sths, anrt map
  487. /*0;
  488.     e
  489. locn arrayst
  490.         photse alread:XP     arm(1)ng paths, ng
  491.     } Pr// subt     arm(2)s good coan ove tankay coordintank re (scaleda clearwoad, r subt     arm(3)nk re (scaledhasr path, then  target at tx,bt     armbecauseioncip ovmoved  vanttingrig rouong patbt     armis p,p
  492. /*0;
  493.     mapgoest
  494. urstarrood osilevant(ob->objay_targ;
  495. locap_siOTHING 0xFFFF>inf!ay_boat;        // Wt_he!is_wet(t){
  496.             GrafPtrstarray_t* 8et(ob->x, X)x << 8;<<8,Y)y << 8;<<8,ath_costs;
  497. loca,    s.placeeeeX)x << 8;get_x, subta<<8,Y)y << 8;get_y, subta<<8,15}
  498. #end>objay_t& !Sam_heas    // Sw+s* 0xay_t&<sendmess    // S)yeight_0;
  499.     if
  500.     re
  501. #endifnd>objayght_0;
  502.  
  503.             GrafPtr{
  504.     cost s0;
  505.     +=ststPo_ost  [    // t
  506. locaRco 0x(e tan-ray_tankhits;
  507. // H}
  508. #end>obj{
  509.     cost s0;
  510.     < 0)    {
  511.     cost s0;
  512.     if (sten    
  513. #end>objt& !S);*/
  514. /*ea;        // s    if
  515.     }#if Ecost_ >objt& !SRIVER*eawoad,++#if Ecost_ >objt& !SG && \
  516. return({eturn(>objtankr= 0)
  517. <    {
  518.     s    // COST+8)n{
  519. 0;
  520.     ifT (UNKNO#if Eccost_ {
  521.     s    // COST_+=s5#if Ecc}if Ecost_ >objt& !SHALFG && \
  522. return({eturn(>objtankr= 0)
  523. <    {
  524.     s    // COST+4)n{
  525. 0;
  526.     ifT (UNKNO#if Eccost_ {
  527.     s    // COST_+=s4#if Ecc}if Ecost_ >objt& !SREFBASE_Treturn({eturn(nfo *ob;
  528.     forrange(t(OBJECT obtype_REFBASE,
  529.         }
  530.     if(b->objec>pillboxOBJECT_HOSTILE))
  531.             in{
  532. 0;
  533.     ifT (UNKNO#if Ecc}if EXP     ->objmapEIN_MASK)
  534. #
  535. // Thurn({eturn(annot rth, es
  536. local would imovedenst arr= 0)
  537. free,eturn(ann cost ng
  538. rray wanlementr= 0), ost_  cost mentcost schost += ->objs.nes, dobui>piltankr= 0)
  539. > {
  540.     s    // COST_+typed    urn({e{
  541.     // tCOST_+=s8;    {
  542.     s    // COST++left  =ccost_ {
  543.     cost s0;
  544.     +=s3c*_UNIT_COST 8    // Th    if(cc}if Ecif Ec: the coset_yd (stuffe Cre.ost' values mapwoad,roodpills & uprogolved,if Ec: tlies i st ntumsetpern of target owuragfally tent
  545. /s,tank getch
  546. // pref Ec: trougeews,ck, atar
  547.  
  548. ,the tank is the actdcisidobu(chapeoutineargwcostaref Ec: tk ishen  e given s
  549.  
  550. // is sqar tank
  551. llea,tlies i st ntumswovedche a// .ef Ec: tst' wovedche a// e thescourb e t recoainc is now,gplayer nt) .ef Ec: te is ns now, ra sittinging oad, rtare bor = tendon, and u i lityd (s    } CostPEc: tet 
  552.  
  553. ,tingordhe who = cipitreachins wovedche a// ess
  554. seoment (gap<answaref Ecour +  && o;, ca_ta    _hea.y&& o;;    // PomeStray_boat;        // W)nk    ifROAD
  555. #end>objt==BOAT*eawoad,    ifc.;        // s    if0extract u  tank is goodrig r,ims tostif Ecost_ >obje tan_hejt&!!SRIVER>pilt&!!S);*/
  556. /*)ber oo  tanvide  cost tostif Ec({eturn(>objc.;        // s)n{
  557. 0;
  558.     ifT (UNKNO#if Eccost_ {e{
  559.     // tCOST_+=s7 0xawoad,; {
  560.     s    // COST_+=s6 0xawoad,; ft  =ccawoad,    ifc.;        // s    if0ex: tky teuristCOST_ty
  561. paidvide  ther costsis    if(cc}if Ec}bt     arost_ %d,%d Cost %de the th_c ost %d" >> 7;arget_x, subtargget_y, subta)#if EXP     >obj{
  562.     // tCOST_A*>ME_COST   0xFF) n    {
  563.     // tCOST_A* 8E_COST   0xFF;XP     >obj{
  564.     s    // COST_A>ELL_COST  0xFF)     {
  565.     s    // COST_A 8LL_COST  0xFF;XP     >obj{
  566.     cost s0;
  567.     >MOUR_COST 0xFF
  568. )    {
  569.     cost s0;
  570.     ifOUR_COST 0xFF
  571. ;XP    bt     arme is isthroughativumeewan 5 cost scsquard imoveit returnsistuproachocal Bn(>objtankcost sc<    {
  572.     cost s0;
  573. )n{
  574. 0;
  575.     ifT (UNKNO#if Ebt     arm>ob{
  576. 0;
  577.     hasr thr sittingbere -erouonT (UNKNOWNieemenwatecal)wo sudted for bcost +=>obj{
  578. 0;
  579.     < T (UNKNO)
  580.             GrafPtrwill  we skip ovount aby (2 * PI the
  581. #end>objtankr= 0)
  582. > {
  583.     s    // COST_)ltankr= 0)
  584. -= {
  585.     s    // COST;  ost_ /ankr= 0)
  586. #s1;
  587. #end>objtankcost sc>    {
  588.     cost s0;
  589. )ntankcost sc-= {
  590.     cost s0;
  591. ; ost_ /ankcost sc#s1;
  592. #end{
  593. 0;
  594.     if{
  595.     // tCOST_+i1,d//ankr= 0)
  596. +ocal//ankcost s
  597. #end>obj{
  598. cost_heT (UNKNO)w{
  599. 0;
  600.     ifT (UNKNO#if Ec}if EXP     cpolou    if{
  601. COST_+iic helps ;XP     >objcpolou    heT (UNKNO)wcpolou    ifT (UNKNO#ifXP     >obj    r.gs, nt = ntx]E>wcpolou)    
  602.             GrafPtr;ray w     if{
  603.     // tCOST;afPtr;r= 0)
  604. #s{
  605.     s    // COST;afPtr;cost sc#s{
  606.     cost s0;
  607. ;afPtr;COST_A* 8;p0;
  608. ;afPtref Ec: te ialready thrted for as usp tankay coorditwo sudd is the or thegutili posi    oot_direediat"Brain.le wooad,    o reacsohis is gns now, rahe sed range +/(gapsi    oot_don = aim(t(s 1608 inMAP necbuffrilinc isuare on = aim(trch heuristactuPillb).
  609. #end>obj{
  610. cost_< T (UNKNOmeStray_boat;        // W)if Ec({eturn(>objc.;        // s)n{
  611. 0;
  612.     ifT (UNKNO#if Eccost_ed    urn({ed    urn(>objtankr= 0)
  613. > 6 0xawoad,)ltankr= 0)
  614. -= 6 0xawoad,;ed    urn(ost_ /ankr= 0)
  615. #s1;
  616. #endtr{
  617.     // tCOST_A+=s7 0xawoad,;
  618. #endtr{
  619. 0;
  620.     if{
  621.     // tCOST_+i1,d//ankr= 0)
  622. +ocal//ankcost s
  623. #endnd>obj{
  624. cost_heT (UNKNO)w{
  625. 0;
  626.     ifT (UNKNO#if Eccc}if Ecc}if Ec(CostPoic,{
  627. 0;
  628. }
  629. #end>objroute = AUTO)ute(CostPoic,w{
  630. 0;
  631. ,trayght_0;
  632. #if Ec}if E
  633. // ****************************************************************************
  634.  
  635. // Gene u_shortplainPK)T_FUNCAN;)buffeLD_YbuffeLteRg  pillcor        Text void explainp_t"Br
  636.     he)buffeLD_YbuffeLteRg  pillcor        Tif (do_explx1_heRAY_SIZE];
  637.  
  638. l-1n_hex2    < 0)    extrac/ T_explx1_ -(XXXXXXXXXXXXXXXX)eLD                    // toann liST_SEostt    edr (i=explx2_heRAY_SIZE];
  639.  
  640. l-1)ex2    =eRAY_SIZE];
  641.  
  642. l-1;oann liST_SE (gap<edr (i=place>0x1<=x2)or        [x1++]++l// return t"Br
  643.     hechos eighthsrangeisthrw
  644. local void addtohepines, )buffeLD_YbuffeLteRg  pillcor        Tif (do_explx1_heRAY_SIZE];
  645.  
  646. l-1n_hex2    < 0)    extrac/ T_explx1_ -(XXXXXXXXXXXXXXXX)eLD                    // toann liST_SEostt    edr (i=explx2_heRAY_SIZE];
  647.  
  648. l-1)ex2    =eRAY_SIZE];
  649.  
  650. l-1;oann liST_SE (gap<edr (i=place>0x1<=x2)or        [x1++]                    // topann lh, thos eighthsrangeisthrw
  651. local void addtohept(&r_to be (PK)T_FUNCAN; p,a_tankxx,a_tankxy,a_tank dowu
  652.     BYTE directix* 8maowu
  653. , targy =y2* 8maowu
  654. rt cost = d
  655. #s1-maowu
  656. rt cexplARRAY(X) ((BY;y)) p(cng)xarggx*/
  657. ,8erage[COST_ARnyeturn(place>0x>y)        if(right>bjr<0)    dA+=s2*y+3; ost_ {    dA+=s2*(y-x)+5; x--; ft  =y++#if EexplARRAY(X) ((BY;y+y)) p(cng)xarggx*/
  658. ,8erage[COST_ARCOST_ARcyf*yd)])#if EexplARRAY(X) ((BY;y-y)) p(cng)xarggx*/
  659. ,8erage[COST_ARCOST_ARcyf-yd)])#if Eexplx<y2*eSty<
  660.     regn({ed    urrectix2* 8y-1;
  661. #end>objARRAY(X) ((BY;y+y2)) p(cng)xa2rggx*/
  662. 2,8erage[COST_ARCOST_ARcyf*yd2)])#if EEexplARRAY(X) ((BY;y-y2)) p(cng)xa2rggx*/
  663. 2,8erage[COST_ARCOST_ARcyf-yd2)])#if EEy2            colEc}if E
  664. // ****oid setcost(ld_pi =
  665. aryint c, u_shortost = dn);
  666.         ifint i;
  667.     Boolean ecti*x* 8&y, c.*y* 8&y,yrt cexpldn);
  668.         i<0)    { x* 8&y,yr y* 8&y,x; ft  0; i<=a[0]; 14if (a[ (pa(right>bj(*x)& !SameSt(*;    // 0)    (*;                colEost_ >obj(*;    /==eRAY_SIZE];
  669.  
  670. l-1)e(*x)            colEost_ >obj(*x    /==eRAY_SIZE];
  671.  
  672. l-1)e(*y)++#if Eost_ >obj(*;    /==e0)e(*x)++#if E(CostPoic, 0)#if Eexplroute = AUTO)ute(CostPoic,w0, 0)#if E
  673. // ****************************************************************************
  674.  
  675. // Geneoid setcostnsigncome_et_y;
  676. lox, MAP_*tY y)
  677.     {*t
  678.     ObjectIostarray_left, c (gapedr  _heap[0eft, costt    ifRAY_SIZE];
  679.  
  680. l-1;Y lasty =ay_boat;        //    {
  681. edr  heap[0eft, c8;
  682.     r.RAY_SIZE];
  683.  
  684. l-1;Y lexpppppp(*tY_ -ap[0eft, costt    XXXXX)e*tY_heap[0eft, costt;Y lost_ >obj*tY_>ray_left, c (gapedr  )e*tY_heap[0eft, c (gapedr ;Y lexpppppp(*ty_ -ap[0eft, c= c.y *XXX)e*ty_heap[0eft, c8;;Y lost_ >obj*ty_>ray_left, c//    {
  685. edr )e*ty_heap[0eft, c//    {
  686. edr 
  687. // *******e ialready*g paths,*k isng
  688.     } Pr//t ob->oss droutcr bclocaurnsis,csohis isws bad and p ovount aneeach dcost tlinseoment// itiven a est_stepdenst aruong pat
  689. typedostPoi realcosre w_ap[0eft,  obtype,tAP_X x, MAP_tY y)
  690.     {ty,a_tankr= 0),a_tankcost s    CostPoint top = cet_y;
  691. lo;ctInfo *ob;
  692.     for (ob = cx,y;XP    bt     first sted for a and(gap<gles map squ
  693. #def,csohbetad,    s= c. gns now,place>wcost al O    *tankx,ihe cast_    /= *tankx,infpast_    /= 0ebug(" (Ftank toastoughittid,    whongays "Hey,ayoupass thdohis i!"nk toanswar// Ifg(" YEStwo st_  cariabhis co'live'h--pt iy<gles eff
  694.     u_tely return This fitime foOBJEC 1,
  695.     st to reac    {
  696.     u_cay_time;        // t    if
  697. ickCight    GetPoap[0eft, costt    >view_left;*/
  698. /*    u_cay_time;        / c.y>view_top;*/
  699. /*    u_cay_tx, subta_A* 8et_x;
  700. loca8;
  701.         u_cay_tx, subty_A* 8et_x;
  702. loc>8;
  703.         u_cay_time;         tank>view_to&& fly    u_cay_time;        /ocap=,tAP_X    u_cayigncome_et_y;
  704. lox&et_x;
  705. loca, &et_x;
  706. loca)#if his fi to nes now,onst SURes
  707.  
  708. #defi    ;, ca_ta    = pillpn-ray_tankhit
  709. /*    u_ca;    // Pom= pillyn-ray_tankhits/*    u_his fiCr minis is now,fa0)
  710. e seingour vitecal r lo
  711.     cha(" (er// an hits thp;*/ottomysreyn ove e
  712. e seingp;*/)colour !ARRAY(X) ((BY;, ca_ta)t_he!ARRAY(X) ((BY;, ca_ty)) top);        _COST-1)
  713.  
  714. turnhis fiIsquarecostankhist  0; i<ya[0]y<RAY_SIZE];
  715.  
  716. l0]y(a[ (pa0; i<xa[0]x<RAY_SIZE];
  717.  
  718. l0]x(a[ (pat{ed    urerage[COST_ARy][x]    if (sten    ost  [COST y][x]    if    r.gs, y][x]    if_COST-1)
  719.  
  720.     colEc}if (ob=&info->objects[0]; ob<&info->objects[info->num_objects]; ob++)
  721.         if (ob->object == OBJECT_PILLBOX && ob->pillbox_strength > 0 && (ob->icolEcfo & OBJECT_HOSTILE))
  722.             if (pat({ed    urn, MAP_Y_he= wx &>>f (sho    x>, MAY y_he= wy) >>f (sho    x>pt(&r_to be (p_t"Br
  723.     he, x-ay_left, costtary-ay_top,  costta8)(sho    x>pt(&r_to be (p_t"Br
  724.     he, x-ay_left, costtary-ay_top,  costta6)(sho    x>pt(&r_to be (p_t"Br
  725.     he, x-ay_left, costtary-ay_top,  costta4)h    if(cc}ifu_cay_time;        /o
  726. // H* 8erage[COST_ARn, ca_ty]Rn, ca_tx] Thinking vso assi record OSTserget from theeragmaowu
  727. , be
  728. // path, then   routineatedpuo thisiatarget  codt(X)
  729. #includx >= int ob->CT_PILLBOX && ob->_het ob->CT_PILLBOXREFBASE)return(>pt(&r_to be (p_ath, ottx-ay_left, costtarty-ay_top,  costta7
  730.     // Thisexplroute = AUTO>pil0)    s is the new ong pteepes fire coverage
  731. localc    {
  732.     u_ctatic unsignensigneP_timrn grey 0, 0 x55,
  733.  
  734. tA,0 x55,
  735.  
  736. tA,0 x55,
  737.  
  738. tA,0 x55,
  739.  
  740. tAect r; unsignensigne
  741.     u_tx, t in arra0, 1,ateR,ateR,20eR,20ect r; nt c, u_shot r; or(&col);blackCil);)h    if(=&infy,ya[0]y,y<RAY_SIZE];
  742.  
  743. l0]y,y(a[ (pat=&infy,xa[0]y,x<RAY_SIZE];
  744.  
  745. l0]y,x(a[ (pat    te(CostPoic,werage[COST_ARnt = ntx] * };
  746. 0)#if ED messag    GetPoror(&col);blackCil);)h    if(Fi&debugwindow;
  747.  
  748. loect, 0, -12,&qd.gocalh    if(ct(&rOval(&tx, t in arr)#if E
  749. /his fiuristhe giv(et_)y;
  750. loxs),he sea ther cstif et_x;
  751. lo.xn E.y * 8et_x;
  752. loca8-ray_tankhit
  753. /*    u_cet_x;
  754. lo.yn E.y * 8et_x;
  755. locyn-ray_tankhits/*    u_cet_x;
  756. lo.ray w         if0extract( are boredrm_seialreadyte ta)colet_x;
  757. lo.r= 0)
  758. * 8e    // Shells amcost ms headingss
  759. cost scwfull cih dcdrm_she secolet_x;
  760. lo.cost sc_he(ost sc*_UNIT_COST 8    // Th    ifet_x;
  761. lo.ooad,         short cot_x;
  762. lo.;        // s    if0et cot_x;
  763. lo.COST_A*    if0et c_size--;                    if0et coCostPoiot_x;
  764. lo
  765. 0)#if >objst_x;
  766. lo.xn !Sam_hest_x;
  767. lo.xn !SRAY_SIZE];
  768.  
  769. l-1n_h r; ut_x;
  770. lo.yn !Sam_hest_x;
  771. lo.y/==eRAY_SIZE];
  772.  
  773. l-1)sendmessld_pi =
  774. aryiot_x;
  775. lo
  776. 1);ssld_pi =
  777. aryiot_x;
  778. lo
  779. -1else
  780. (place>0ze) addtoh        CostPoint temp   cE=st)mheap(void)
  781. )#if Els Exite are borst routhen  target atal O    cour +  && o;, ca_ta    _hea.y&& o;;    // Po) top);        ;COST)#if Els se,
  782. // asue;    // satrch heuristdowhere XP     c.y--; (codt(Xi;);wy,y(ast_hea,x(a; (codt(Xi;);wy,x            colEy,y(as (codt(Xi;);wy,y            colEy,x--; (codt(Xi;);if E
  783. //(char *f"N finding  giveget
  784. //ost %d" >neary) call tebug("%d,%d CN finding  giveget
  785. //ost %d" >neary) call tebugtop);        T (UNKNO)
  786. // ******* x, y)ngaythe tanwfull cih dseomeoecifieeadingss
  787. cost scss thew muistweponlynd immedialies h dcdrm_she secorns zero if
  788.     rem>ob{ findingtarget tion from thcmedial de =
  789. te: thOTE:te is ns nownt positiocost scnewrectisquarge +/eque takecdrm_t Scost ss soono sudALLfindinhis cofailurmall(T isuare htrolrulovouesr thr pprds wieeadin.)e 'cost'  now,pss d valuur/ estime; who = ve h5 cost s, eare e is a htrol cost foisI the
  790. #oolean safe_bage(t(ute 
  791.     };
  792.  obtype,tAP_X x, MAP_tY y)
  793.     {ty,a_tankr= 0),a_tankcost s    CostPoicoutx;t_x;
  794. ca8;
  795.         u_ccouty;t_x;
  796. c>8;
  797.         u_c
  798.     Boo, 0;
  799.     sh1;Y lredomtte ->y,te short time;        ,te 0;
  800.     ifT (UNKNO#if  raw_getute 
  801.  becomeuct { signeearx, po regxesired unt a cif (cr  regoneanms to roct { signeearxY po regy;en we are onquare
  802.     } CostP{ signeredomyersay_tankhitar  he,20me squristhe searenly
  803. #define    if >objendmescost sc<kcost s    , 1(char *f"Insufficiitiocost scftank re == OBJm_s");wextrac;
  804.     retu }if his fiIin coststucstarrmaz0 squaCOSyt_stepdh dc
  805. locatwo suhis ficun deepcornsisee sea regoneanover una clear pde. I (c0.5 lls remediaproceeacCOSyt_a#inouslargelowlarg  giv(scaled wie    } CostP>objendmes cosob        // Ueac_hetse_to_mine;
  806. locac_heendmesspeeds<=+ 0x4h        Cos po regx    = pillp; po regym= pillyu }if >obj{o regx    == pillpn_hepo regym== call to0;
  807.     sh2urnhis;, ca_ta    = pillpn-ray_tankhit
  808. /*    u_ca;    // Pom= pillyn-ray_tankhits/*    u_ his fiIinoordinre =ld squa tank toCoset_distan squaCoset_dob-> valuesnd don'orditw
  809. local    hasrne eledoot_stepdh dget  d shore weay, noocludcayigncome_et_y;
  810. lox&et_x;
  811. ca, &et_x;
  812. ca)#if >obj;
  813. locan-ray_tankhitsay w>myersay_tankhitar  _h r; ut_x;
  814. loca8!=;t_x;
  815. ca8_hest_x;
  816. loc>8!=;t_x;
  817. cy _h r; ay_time;         tank!>view_to&& flyt_heap[rarg;
  818. locap_sit ob->_h r; a, ca_ta    < 7t_hea, ca_ta    >=eRAY_SIZE];
  819.  
  820. l-7>_h r; a, ca_ty    < 7t_hea, ca_ty    >=eRAY_SIZE];
  821.  
  822. l-7)u_ctatic unsignensigneP_timrn grey 0, 0 x55,
  823.  
  824. tA,0 x55,
  825.  
  826. tA,0 x55,
  827.  
  828. tA,0 x55,
  829.  
  830. tAect r; unsignensigne
  831.     u_tx, t in arra0, 1,ateR,ateR,20eR,20ect r;  cost;        // Ov r;  old;
  832.             RgnHanexplroute = AUTO)
  833.             GrafPtr &old);
  834.             SetPort(debugwindow;
  835.  
  836. loSetPortor(&col);blackCil);)h    if((Fi&debugwindow;
  837.  
  838. loect, 0, -12,&qd.gocalh    if((ct(&rOval(&tx, t in arr)#if Ec}if E0;
  839.     ifre w_ap[0eft,  tAP_X in at r= 0),cost s    gnHanexplroute = AUTO)
  840.             GrafPtr>objay_targ;
  841. // W)nor(&col);plateCil);)h    if((ost_ or(&col);blackCil);)h    if((ct(&rOval(&tx, t in arr)#if Ec(old);
  842.             BlockMo}bt     ard unt all cih drossdhan 5 square%> vat scsay wted for as u reac    {
  843.      XP     yersay_tankhitar  he(
  844. ickCight    Gn-ray_tankhitsay 80 +20gnHanexplyersay_tankhitar  < 6(X) yersay_tankhitar  he60gnHanexplyersay_tankhitar  > 5.bluyersay_tankhitar  he500gnHanexplcost_==eT (UNKNO)wextrac;
  845.     return(E
  846. /his0; i<=a[0]; 8if (=0;
  847. )u_ctatic rectix* 8a, ca_ta+ding =
  848.     {.s.s8ii]. ;tic rectiy* 8a, ca_ty+ding =
  849.     {.s.s8ii].y#if EexplARRAY(X) ((BY
  850. )    _heARRAY(X) ((BYy)    _he,te 0;
  851.     > ost  [COST y][x]f (pat({ed    urn,te 0;
  852.     ifost  [COST y][x];ed    urn,te RLD_XX)x << 8;(x*/ay_tankhit
  853. /*)<<8) & 0x20;ed    urn,te yLD_XX)x << Y)(y*/ay_tankhit/ c.)<<8) & 0x20;ed    urn}if E
  854. //itx - (l,te RL)y);
  855.     Mankx, info->t,te yL)y);
  856.     Mankx, infoa)#if >k>vi    if  >>f4)
  857.  
  858. /#if on_votes[16];
  859. li]A+=s100gnHaute 
  860.  becomek>vellW(x,y)];tte ->,te y)#if >objinboat && fly[ (pa(right>bjute 
  861.  becomek>= BOAT*eon_maxspeeds[16];
  862. g[i];32;bt     arm>objute 
  863.  becomek>= RIVER>pilrees >= 4)
  864.  ?)ngs, pusp rid sho; isp tan??    return(cost);
  865.     }
  866.  
  867. // ****************************************************************************
  868.  
  869. // Route fCassi_SEintur
  870. 1,
  871.     ]; ob++ m(trch hcreepecn placelriabl= veess;            //  un#deff tar tlin= vees 's;            // ' eightd return until;e == OBJa tan'until;say 'csackall(until;say ==0ed i if*ount * until;)neoid setcost= veess;            // (sInfo *tankprop, nore_until;say 8CostPoip->ng_progress;    // Cu    ifT (US 0xFFFFebug(" Muthe tahere -eroogress;            // csay  squaC +/(sl    havdeep pbug(" marin c'bo es'ment
  872. localitial sgn 5 say r1(chn_msPoip->ogress;            // c=w;
  873. loca    ifuntil;say ;Poip->until;            //  c=w;
  874. loca    ifuntil;say ;Poi}returns zero if
  875.     }m>obn_boafre hs, a;            // 
  876. #oolean safe_bar long yss;            // (sInfo *tankprop, remaining_progre    // This ware alreadyn_boafre hs, a;            // ,ntank re  coan_taal r e locatapbug(" d imovent atourgetf; isprget_day  so sudgn);
  877. p pbug>objmg_progre < p->ng_progress;    // Cu    _he;
  878. locan-rp->ogress;            // c>ION_SPAN (60*20) +2[ (pa(righp->ng_progress;    // Cu    ifng_progre;righp->ogress;            // c=w;
  879. loca;if E
  880. //(st_ >obj;
  881. locan-rp->ogress;            // c>ION_SPAN (60*20[ (pa(righ(char *f"N fs;            // "turn(E= veess;            // (p, time = ATTEturn(E= trac;
  882.     return(E
  883. /(TRUE);
  884.     }
  885.  
  886. local void explain
  887. #dde_g paths, obtype,loca, remainies[1, nore_ ->ynore_ yrtost = h > 0 &&Tif (do_explendmess    // S)u_ctatic ut;
  888. locac=wlocal Bc ut;
  889. osts;
  890. loca    ifrarget_path    [NU#if Eexpppppp(locac=T_PILLBOX && ob-)ng patosts;
  891. loca    ifary_target_path, base-#if Eost_ >objlocac=T_PILLBOXREFBASE)ng patosts;
  892. loca    ifary_target_path, base-#if Els rem runaw  coan_afey)ngohis is gnsmhowroesr thif Els he vicinitocal    jume sh already 1,
  893.     so  0 calc    n  0emynHanexplri
  894.     < 0x9.bluon, runaw    if
  895.     }#if Eexplri
  896.     < 0x2.bluon, ri
  897.     if
  898.     }#if Eost_ >objri
  899.     < 0x780)
  900.             GrafPtrost = 0;
  901.     ifst(info->tankx,info->ttanky)
  902.  
  903. //,ng patosts;
  904. loca,  x, y) >;
  905.  
  906.     // Tend>objay_t& !Sam_heh > 0 && +s* 0xay_t&<sendmess    // S)yon, ri
  907.     if
  908.     }#if Ec}if E
  909. // *******he cossument a-ero"s    // S" (get from thd to reocal) greoad,    squar20e(ll ced_s    // S)u_ls sank to getreyn
  910. #ddehis isitwroesnt all cih drefuelmbecauseii
  911.     hasr>ares     // Su_ls we a
  912. #ddesp p,run thrases, rget.
  913. // Tmbecauseii
  914.     hasr< (scal 3es     // Su_ u_long findranneM((s]; ob++
  915.     {
  916.     CostPoi
  917.     Booleannore_ ->y short_tankr= 0) he,0eRcost sc#s0gnHasInfo *tankprdummygnHasInfo *tankpr*s;            // 
  918. // Tm= &dummygnHanfo *ob;
  919.     for (obnfo *ob;
  920.     fpillte 
  921.  get= 
  922.     } (obnfo *ob;
  923.     fpillte 
  924. erag= 
  925.     },    fpillte 
  926. frnowbits
  927.     } (obnfo *ob;
  928.     fpillte 
  929. , 16= 
  930.     },    fpillte 
  931. refuelmts
  932.     } (obremainies[1 (obremainiyersMAX_VIS(s., laymim_heh.anks, attacm_heh.anks, & info_heh.anks, r wat)
  933.             ?fT (UVIS+ 1 + C: DEFENSIVE+ 1 +  (obremainiattadg=Y) (_es[1, & indg=Y) (_es[1, frnodg=Y) (_es[1 (obremainibth th=Y) (_es[1, refueldg=Y) (_es[1 (obremainilimitsMAX_VIS) (_es[1 (ob do_showr
  934. #dded    if
  935.     re
  936. #e_tankll ced_s    // Si];30eRuseful_s    // Si];6uct { signe_tankogrescost s_
  937. loca    if0et c_si***e ialready u i refuelriablbTsergetnnwfull circle r= 0),awould ima pbug("         //  d imovedgo
  938.     e
  939. OSyt/ pi r= 0) e given sts terse,
  940. // asws bg(" dragpe aupee seaasrfewaasrresf; igutilitytr=
  941. riablag =
  942. p
  943. /*    if ( don't c ove e
  944. ankelementby r wateis ismovedrectisquar6kr= 0) h dsiv .ef >objellW(x,y)];ankx, info->tanky)
  945.  
  946. // & !SREFBASE_Tretur{kll ced_s    // Si];4[0]useful_s    // Si];1u }if his fiIind imovedng
  947. rankytr);arra 1,
  948.     a pillby r wat(s 1608already thruntilgre    // explendmesr watpil;
  949. locan-rr was;            // [endmesr wa->udnum].until;            //  >={
  950.         x += siMAX_VISange_to_me(OB) finendmesr waturnhis armour the sths, renl pprds wir watealreadynon a threif Eexplri
  951.     < 0x80)
  952.             GrafPtr***e ialreadylosiablagst scjutyer nt) dng
  953. how)wo sudoitdestinews,t_ed    ur>objendmescost sc<kogrescost s_
  954. locaf (pat({ed    urn= veess;            // (&r was;            // [endmesr wa->udnum], time = ATTEturn(Egh(char *f"Ab't  u   wa!/ost %d" >endmescost s,kogrescost s_
  955. locafh    if(cc}if Ec***e ir wathasrjume rcley refuelr & us, mariurnsist" ove tlgre"ed    ur>objendmes== 0)
  956. #de4fo->man_stacost sc#= 8)ed    urn= veess;            // (&r was;            // [endmesr wa->udnum], 0)#if Ec}if EXP     ard uialrWANTih drefuel?right>bj(endmes== 0)
  957. <kll ced_s    // Si_heendmescost sc<k8)    _hese(ObjectIendmesr wat)
  958.             GrafPtr***chedi ir wat the upprds e +/equ reocalshore weiis gns"pillte 
  959. refuel"ed    ur do_showh, bs    // Si];(endmes== 0)
  960. <kll ced_s    // Si->man_star wa_s    // Si>={useful_s    // SBlockMovdo_showh, bcost sc#sjendmescost sc<k8XXXXXXXXXXXXX->man_star wa_cost sc>    MIN_BASE_UNIT_C// Tend>objh, bs    // Si_heh, bcost s) {e{llte 
  961. refuelmtsan_star wa; refueldg=Yes[1  }if Ecost_ (pat({ed    urn(char *f"RefuelriablbTserexhao tak"fh    if(cc= veess;            // (&r was;            // [endmesr wa->udnum], time = ATTEturn(Egh}if Ec***ost_ >obr wat tht a-upprds e +/equ reocalshoreriurns tlgre,csohis iif Ec***afad,    wedgo fardenst arom it_SEotepd{ siured t, 0est
  962.  
  963.  
  964. ty,if Ec: twdyn_boafand p oveom
  965.         tarraymiablbT, re tanf; ispplaceif Ec}if E
  966. /eanngrescost s_
  967. loca    ifendmescost s Thinkinbuangexnf; i0.99.2bne MAX_HEAGOODTANKbject Y_>r / 0x1>x == wx &< 0xF0x1>x == wxy_>r / 0x1>x == wxy&< 0xF0x1)
  968. /his0; i<o->objects[0]; ob<&info->objects[info->num_objects]; ob++)
  969.         if (ob-atic uwitdesject == OBJ)
  970.             GrafPtrc watPILLBOXTANK:eturn(>objGOODTANKbpil;
  971. locan-r
  972.  
  973. /s;            // [o & Odnum].until;            //  >={
  974.         x     b->object OBJECT_HOSTILE))
  975.             i    s.placet>bj(MAX_VISange_to_me(OB) finob)TE)(attadi    s.place    {e{llte 
  976.  get= or iattadg=Yes[1  }if Ec        // OKafPtrc watPILLBOX && ob-:    if(b->objecox_strength > 0 && (ob->icolEcurerags;            // [o & Odnum].until;            //  -l;
  977. locan> time = ATTEt    s.place= veess;            // (&erags;            // [o & Odnum], time = ATTEturn(Egh>obj;
  978. locan-rprags;            // [o & Odnum].until;            //  >={
  979.         x     b-{ed    urn(ost = h > 0 &&_he= wy_strength > 0 &&#if EcccMAX_VISange_to_me(OB) finob)
  980. #endnd>objh > 0 &&_h=l0)    s topannD teres
  981. // If w    x     b-{ed    urn(cMAX_V+=s16*256;    s.placet>bjfatal_xype &&wx &>>f bpilfatal_yype &&wx) >>f i    s.place    = veess;            // (&erags;            // [o & Odnum], 6*60*60*60)
  982. #endndEost_ >objri
  983.     < & ind) {e{llte 
  984. erag= or i& indg=Yes[1  }if Ec    cc}if EccEost_ >object OBJECT_HOSTILE))
  985.             iopannHon_boeres
  986. // If w    x     b-{ed    urn(cMAX_V+=sh > 0 &&*256;    s.placet>bjri
  987.     < & ind) {e{llte 
  988. erag= or i& indg=Yes[1  }if Ec    cc}if EccEost_ >objh > 0 &&_< 15/ move gaFrie
  989. ry damageeres
  990. //  w    x     b-{ed    urn(ct>bj(MAX_VISange_to_me(OB) finob)TE)(frnodi    s.place    {e{llte 
  991. frnow= or ifrnodg=Yes[1  }if Ec    cc}if EccE}if Ec        // OKafPtrc watPILLBOXREFBASE:rn(Egh>obj;
  992. locan-rr was;            // [o & Odnum].until;            //  >={>x == k!>view_to    {
  993.     Objurn({ed    urn(>object OBJECT_HOSTILE))
  994.             i    s.place{ed    urn(ct>bjh.anks, r watX->man_stas    // S)u_cturn(ct>bj(MAX_VISange_to_me(OB) finob)TE)(bth t)u_cturn(c    {e{llte 
  995. , 16= or ibth th=Yes[1  }if Ec    cc}if EccEost_    s.place{ed    urn(ct>bjendmes== 0)
  996. <kll ced_s    // Si_heendmescost sc<k8)u_cturn(ct>bj(MAX_VISange_to_me(OB) finob)TE)(refueldg_hese(ObjectIob)Tu_cturn(c    {e{llte 
  997. refuelmtsor irefueldg=Yes[1  }if Ec    cc}if EccE}if Ec        // OKafPtr}if E
  998. //his fip indgwsh al(gapedch dco cost fboxes
  999. //  h > 0 &&_--ngexniT_tyif >obj{llte 
  1000. erag)i& indg=Yange_to_me(OB) fin{llte 
  1001. erag)ebug(" (Weentiallch dcses, rw/ Ores
  1002. // Ifeen{ sd ms htoset_oll ciexcep a
  1003. fines fip in// Ife/ Tmostt    _boaf/ pi becauseis nyon sdy t_tely retuhit sat.) This fiIfedamageeres
  1004. //  pillby,ngexniTif >objs.d tair& info_hepllte 
  1005. frnowpilfrnodg< DEFENSIVE+ 1 + ->icolErees >= 4)
  1006. pilCAN_DO_G && \
  1007.  
  1008. pilH(X,Y) (ppllte 
  1009. frnose->ypllte 
  1010. frnosey)
  1011.         CostPoiiew_to    s, pwx &&ypllte 
  1012. frnose &>>f (sho    iew_to    s, pwxy&&ypllte 
  1013. frnosey&>>f (sho    iew_to    s, pwxa aim(tx G && MODE_Pob-#if E
  1014. /his fiot rarryas uspes
  1015. // , would imoveda hon_boer getpillby,nuseii
  1016. ?if >objCAN_G && X && ob->pils.ppoffensm_shpiltankd&< 0xD0
  1017.         x += si, MAP_Y_heankx, info- +e{llte 
  1018.  getse     // c9 ((x>, MAY y_heankx, infoy +e{llte 
  1019.  getsey    // c9 ((x> raw_getmapE=stapcell((X),(Y)
  1020.      y    gnHanexpl!jmapEIN_MASK)
  1021. #
  1022. //     _head_pis, p_es
  1023. // [mapEIN_MASK)
  1024. #def]->icolEcH(X,Y) (pX)x << 8;<<8, Y)y << 8;<<8t)
  1025.             GrafPtriew_to    s, pwx &&yx;afPtriew_to    s, pwxy_hey;afPtriew_to    s, pwxa aim(tx G && MODE_Pob-#if Ec}if E
  1026. /eanexpllimitsMAX_V>ibth th )ilimitsMAX_VISbth t;eanexpllimitsMAX_V>irefueld)ilimitsMAX_VISrefueldleannimitsMAX_VISllimitsMAX_V +2[ +eDEFENSIVE+ 1 +  (obexpllimitsMAX_V>i) (_es[1)ilimitsMAX_VIS) (_es[1 (ob: tlimitsMAX_Vnew onlimitat scheuris,csoh ovount ago eoecc: tk isode of it
  1027.  
  1028. #
  1029. /*    ifnf; ispd teres
  1030. // e areecc: tk ileda cng
  1031.     } Prhan 5 menwrtat = 2;            nexveomus.
  1032. /his fiud byalentitlgty:vount ahe vicmhow costarratal O    >obj;
  1033. locan-rmholtecuas;            // .until;            //  >={>x =iew_toh,(X{ siure> 1
  1034.         x += si RLD_iew_toh,(Xx;afPt yLD_iew_toh,(Xy;afPtMAX_VISge(tx, ty, x, y) >ankx, info->tanky)
  1035.  
  1036. // ;righp;            // 
  1037. // Tm= &mholtecuas;            // gnHanexpliew_toh,(ob        // Ueac_heMAX_V>i0x2.blu{wr
  1038. #dded    if
  1039.     }# (char *f"Reecu PrhMan"tu }if E
  1040. /his fiFep isntitlgty:vhon_boer gets/p in// Ifes 1608eadye seingg paths, x, tyif his fiIind imoveda pillby lso diwe awe'ady thrcses, k, also snky;nc unaTif >objtankd&< limitsMAX_VeStrh.anks, attac)iattadg=YlimitsMAX_/ This fiIfed imoveda pillby es
  1041. // , we awe'ady thrcses, k, aes, refbasey;nc unaTif (" (unrectirnsistfor mpletuhpug pver    // expl& indg< limitsMAX_VeStrh.anks, & inf)t +=>obj{llte 
  1042. eragox_strength > 0 && (oendmescost sc_h r;     {llte 
  1043. eragox_strength > 0 && (oendmess    // Si +2[ & indg=YlimitsMAX_/ Thisexpl!r
  1044. #dded    eSt(tankd&< limitsMAX_V_he& indg< limitsMAX_)[ (pa(right>bjtankd&< & ind)have removeda hon_boer getaps;    ac} Prregn({ed    urrectid to reabcost sc#sjtankd&>eDEFENSIVE+ 1 + ) ? 6 : t"Bymiab_s    // Sh    if(ovdo_showll cs_f(gap<<1endmess    // Si> 5o->man_stacost sc>id to reabcost s;
  1045. #end>objtankd    < 0x80am_hell cs_f(gapf (pat({ed    urnMAX_VIStankd;    s.plat &&ypllte 
  1046.  getse ;    s.platy&&ypllte 
  1047.  getsey(sho    x>p;            // 
  1048. // Tm= &
  1049.  
  1050. /s;            // [pllte 
  1051.  getseOdnum];eturn(annNoied byaler long yss;            //  itiven ab_  care cih d_stepdMAX_;nc ed    urnM
  1052. #dded    if
  1053.     }#rn(Egh>objll cs_f(gapf (pat(-{ed    urn(os// Si];20;Rcost sc#sd to reabcost s;
  1054. #endgh(char *f"Ases, k, also : %lu, %lu (%ld s%ld)",    s.place
  1055.     MAP,
  1056.     sho, Ytx-ankx, info-)sho, Yty-anky)
  1057.  
  1058. // asty#if EcccM
  1059. #dde_g paths, obtypeXTANK,ies[1,  x, y) >9)#if Eccc}if Eccost_ed    urn({ed    urn((char *f"Fleek, also : %lu, %lu (%ld s%ld)",    s.place
  1060.     MAP,
  1061.     sho, Ytx-ankx, info-)sho, Yty-anky)
  1062.  
  1063. // asty#if Ecccrunom itif
  1064.     }#rn(Eghc}if Ecc}if Ecse{ cost_urn(annNllte      } Prhistfohon_boeres
  1065. // regn({ed    urrectih > 0 &&_he{llte 
  1066. eragox_strength > 0 &&;ed    urrectid to reabos// Si];h > 0 && +sh > 0 &&/2;ed    urrectid to reabcost sc#st"Bymiab_s    // S +sh > 0 && ? (2 +sjh > 0 &&+2)/3) : 0;afPtref Ec: t????id to reabcost scUSEDih dr it_his:ef Ec: tl& indg>eDEFENSIVE+ 1 + ) ? 6 : t"Bymiab_s    // SCOST_SEh > 0 &&/4#if Ecls we atinewmadweiisafraidch dpi, ruppd teres
  1067. // Ifeeflocal    ha c oRcost s!afPtref Ecvdo_showll cs_f(gap<<1endmess    // Si>];h > 0 && ->man_stacost sc>#sd to reabcost s;
  1068. #endif Ecls Ccif (cr es
  1069. // eisafews o:ef Ec: t1. Ie actd, tyrouslad_stepd(do Iyn_boafneeachine?)ef Ec: t2. Wl cih df(gap<iiif Ec***3. Ie'sdf(gap Prhusif Ec***4. Ie actd terlbdima pk, alurb epi, e COS
  1070. #end>obj/*& indg< 
  1071.     ifm_he*/ll cs_f(gap<_heenBymiab_s    // SC> 1m_heh > 0 &&                 return({ed    urnMAX_VIS& ind;    s.plat &&ypllte 
  1072. eragox ;    s.platy&&ypllte 
  1073. eragoxy(sho    x>p;            // 
  1074. // Tm= &erags;            // [pllte 
  1075. eragoxOdnum];eturn(expl& indg<  0x400pils > 0 &&                 return(    {rpragsi, upca8;
  1076.     ast;rpragsi, upc>8;
  1077.     ast;r}ed    urnM
  1078. #dded    if
  1079.     }#rn(Egh>objll cs_f(gapf (pat(-{ed    urn(os// Si];20;Rcost sc#sd to reabcost s;
  1080. #endgh(char *f"Ases, k, aprag: %lu, %lu (%ld s%ld)",    s.place
  1081.     MAP,
  1082.     sho, Ytx-ankx, info-)sho, Yty-anky)
  1083.  
  1084. // asty#if Eccc>objh > 0 &&_/ 0)    M
  1085. #dde_g paths, obtypeX && ob-,ies[1,  x, y) >h > 0 &&T#if Eccc>objhn, ri
  1086. )ar long yss;            // (p;            // 
  1087. // T >h > 0 &&T#if Eccc***e ialreadygoestuong pat
  1088. epes fire c so sudt scalgtertargetif Eccc***re hs, a;            //  actwcostarialreadyanklic as usny damageif Eccc}if Eccost_ed    urn({ed    urn((char *f"Fleek, aprag: %lu, %lu (%ld s%ld)",    s.place
  1089.     MAP,
  1090.     sho, Ytx-ankx, info-)sho, Yty-anky)
  1091.  
  1092. // asty#if Ecccrunom itif
  1093.     }#rn(Eghc}if Ecc}if Ecse{ c
  1094. /his fiu
  1095. #defsntitlgty:vAses, dng
  1096. r 0emyir wathisexpl!r
  1097. #dded    eStbth th< limitsMAX_)        x += siMAX_VISbth t;eanat &&ypllte 
  1098. r wa->x;afPt yLD_pllte 
  1099. r wa->y;righp;            // 
  1100. // Tm= &r was;            // [pllte 
  1101. r wa->Odnum];eturM
  1102. #dded    if
  1103.     }#rn(E(char *f"Ases,  B wa: %lu, %lu (%ld s%ld)",    s.pl
  1104.     MAP,
  1105.     sho, Ytx-ankx, info-)sho, Yty-anky)
  1106.  
  1107. // asty#if Eos// Si];20;Rcost sc#s0me sqDunt aneeaccost s,kwe aoaneeaclots ms headint +=>obj{llte 
  1108. r wa->refr wa_s > 0 &&T    M
  1109. #dde_g paths, obtypeXREFBASE,ies[1,  x, y) >30)#if E
  1110. /his fiThirfsntitlgty:v uialrneeach drefuel?rigexpl!r
  1111. #dded    eStrefueldg< limitsMAX_)        x += siMAX_VISrefueldleanat &&ypllte 
  1112. refuel->x;afPt yLD_pllte 
  1113. refuel->y;righp;            // 
  1114. // Tm= &r was;            // [pllte 
  1115. refuel->Odnum];etur***e ial'ady u r wa; ount aget time if Eexplri
  1116.     < 0x80)
  1117.             GrafPtrr long yss;            // (p;            // 
  1118. // T >400-1endmess    // Si-man_stacost s*5}
  1119. #end0; i<=a[0]; 16if (a[.
  1120. // T_MAX_;nc 
  1121. g[i];0#if Ec}if EM
  1122. #dded    if
  1123.     }#rn(E(char *f"Refuel: %lu, %lu (%ld s%ld)",    s.pl
  1124.     MAP,
  1125.     sho, Ytx-ankx, info-)sho, Yty-anky)
  1126.  
  1127. // asty#if Eos// Si];0;Rcost sc#s0me sqDunt aceadyes iswsdcdrm_she se,iven a estustk ileif E
  1128. /his fiot  thrM
  1129. #dded    rra ny    } Pr//t sudd ileda cleahk, alurb etime he secolexpl!r
  1130. #dded[ (pa(right>bj!s., laymi) 0; i<=a[0]; 16if (a[.
  1131. // T_MAX_;nc 
  1132. g[i];0#if Etop);        T (UVIS+ 1 + turn(E
  1133. /(
  1134. /(TRlong yss;            // (p;            // 
  1135. // T >MAX_)et c_sig patoon = aim(tx - (l RL)y);
  1136.     Mankx, info->t yL)y);
  1137.     Mankx, infoa)#if g patoon 16];
  1138. * 8e    patoon = aim(tif  >>f4)
  1139.  
  1140. /#if >objm) >h >daEgh>objll cs_f(gapf (pat(-{s),hta aimif Ec(MOUR_COST 0xF"+ses, info-)sho, Yty-anky)
  1141.  
  1142. // asty#if paphinki
  1143.         C"for (ob = c*            C"for (ob ="*1toon 16]placW*'x 
  1144. erag= oink_8;get_x, syjst s*ey>p;    r (oX_VISrV(oX_VISdd ileda rial'a6ISdd ilpllte 
  1145. frtx - (s[1  }i;,Y)y << 8;<<llyu }Ytx-ankx, info-)sho, Y0es0me sqDunt=me sqDllte 
  1146. frtx -
  1147.         co,(MOUR_Crgn({ed    urrectid to reabcostOUR_Crgn({ed    6ore, odt(gwo rellte 
  1148. erayenow,fo-)sho, ;etebuOTE:te nVISdd ileda rial'a6Yty-anky)
  1149. OUR_Crgn({ed    6x({ed    =ay_boat;        //    e*    u_ca;    // Pom= piathsy)
  1150. ueldtohepines, )buffeLD_YbuffeLteRg  pT 0xF"+ses, buo, ;etebu/H/#if Eexpace-1)>>1;
  1151.         }
  1152.     }?g pat
  1153. iTy damageif fines fi0"}
  1154.     }?gotankd&fueldg_hese(apgoest
  1155. urstaree_",    s.plae 
  1156.  becomx,ar 
  1157. loc**;    /s    gnHanefines fi0"}
  1158. iTy damayc 
  1159. ohepines, )buoc**;    /s*;    /cquarem
  1160. /his} CostP{uo, ;eteT
  1161. urstarety-anky)
  1162.  
  1163. urstarety-anky)
  1164.  
  1165. urstarety-anky"for (ob 
  1166.     } (Ei ca_tldamayc 
  1167. ohepineob 
  1168.     }0ot    6ore,h(char *fngth > 0 & in a_pis, p_es
  1169. // [mapo reAh hcreepecn = or ib)d for as u reac    {
  1170.      XP     yersay_tanN)y);
  1171.     M
  1172.     < 0x2.blG 
  1173. // Tm= &roVE+ 1 + )st scneip ovount aby (2 *tat sc;(cMAX_V+hrcses, k, als nVISdd ileda rial'lky)
  1174. u5%e 
  1175. eragox ;    s.pl}if E
  1176. /eReragox>positioc_eteT
  1177. urstarety-a:osts;
  1178. locphinki
  1179.         C"for (ob 0, a7cUSEDih Uay_tim'a6ISdd ilpllte(USEDih_N    C"feanat &&ypllte 
  1180. refuete(USEinfoa)#xlo<"ida rifrtx - (s[1foa)#if ost sc<k8ie  x, y) get_xop);    16if aget0pils > 0 "Bywsitioc_ete2.blu{wr
  1181. #dde2scad_stepd(/ c>IOllte 
  1182. refuypeX1i_ll)as;
  1183. l
  1184.     Mplayer ed    ioc_etE1i_ll)as;mme=D3o_mine;o reAh hcre{wr
  1185. T)VISdd ilpis, 
  1186. erayeheae 1 + ued    ioc<#rn(Egh>rn(os/at &&ypllte 
  1187. refuel->x;afPt scneip ovouine;o  Egh>rn(os/apturns zerod    ioc9eactuPilllcor        Ti
  1188. erag= oint s*eyip ovda   g pato
  1189. /his}1foa)> 0oint s*ef Ec}if E
  1190. /eanexpllioat;        //obj    r.gG 
  1191. // ng_prost %d" >near(=frtx - (s[1foa)(do_explendmess    // S)u_ctatic ut;
  1192. locac=wlocal Bc ut;
  1193. osts;
  1194. loca    ifrarget_path    [NU#if Eexpppppp(locac=T_PILLBOX && ob-)ng patosts;
  1195. loca    ifary_target_foa)> 0oin reAh hcrs,kwe aoan;(kpat
  1196. iTy damageifPgypllte >n grey 0aw    if
  1197.     er    // foa)>info->t yL)y);
  1198. ;unsitioc thcmediw reAh hcemp;
  1199.         pbgox ;    dmess    // C',    s.plovouine;o  uriw reAh hcpll+ Egh>rn(os/aptuaceiw rea)> (res
  1200. //  pillho, Ytx-ankx, info-mine;o reAo  uriw reAh hcT_ARcyf*yd)])#if EexplARRAo & OBJECT_HhcTeCil);)n 16];gth pis, 
  1201. erayght_0;abexplARRAo e 
  1202.  Bpf (pat(-{ong,csoh ovount ago%u4-pc}if EccEost_ >obr wa->y;righc    pSamdnum], }b&();)n 16];gtoMg16];gth pis, 
  1203. erayghan_stacost sc>#sd to reaGWFobr wa->y;riS
  1204. iT}b&();)Ah hcT_Asr w& \
  1205. return({ereAh s    / (Ei ca iswsdcdrm_she se,iven a estueine;)+2;    pbgox ;    dmect == wum], }bets/p "Fleek, s/p "xp*;    /s    gn+hrcses, k, efuyplel
  1206.     MAPk- epi, e COS
  1207. eek, s/p "xp*;    /s    gn+hrcses,)
  1208. > {
  1209.     s    /y(f >objm) >h ip->orety-anky)
  1210.  
  1211. urstarjm) >h ipn  [COan_sO2scad_stie  x, y)0rjm)  (ob 
  1212.     } };
  1213. 0)#i, x, y)0rj};
  1214. 0eif Eafneeachine?E!ifrtx -"xp*;    /s    gn+hrc.. = (CPCosrealcosf Eafne/  >={>Tm= oto fboxes2scado fbooendmescor>ial'lky)
  1215. 5Egh>oo
  1216.         x += s0)#i, x,u, %lu (%ld s%Hrtx - (s[1foa)(do_explendmess    // S)u_cta{xmrgetf; x* 0)    {
  1217.     coreip?fo->tanky)
  1218.  
  1219. //fi0s%Hrtx - ne;o  ur =debugwt scneip s%Hr9(eip s%Hr9(ei    /s    gn);        T (hepines,IStankd;T)f(gapf (pn safe_te 
  1220. et_xop);    16i he,0eRc];gtoMg1((gap<_he})(sho    x>pt(&r_to be (p_t"Br
  1221.     he, x0| "Br((s]; ob++
  1222.     {e,0eRc];gtoMg1((gap<_he})(shoVISange_toa
  1223.  
  1224. ursey;nc -xXP     yec_ete2./ T Ec(MOUR_Cexrial[a(0c(MOUR_C_ 0;
  1225.     sh1;Yfepd(/ c>IOllted    rra nyiew_ts;w)    {
  1226.     coRc];g
  1227. local voiriS
  1228. iT}b&();)Ah hcT_As    ifrarge    ?+nii];(endmes== 0)
  1229. <kll IOllted    rra ny(gap<_he})(sho.r washso.*];g
  1230. loc3n    M
  1231.     < 0x2.blG engthif*ount * uneoX_VISddf*ount * una ny(g.;Bgth,tAP//  p+p,a_tankcost s    CostPoint top = cet_y;
  1232. lo;ctInfo *ob;
  1233.     for (ob = cx,y;XP    bt     first sted for a and(gap<gles map s%sted fnfo-)sho, 
  1234.     co:    ]at
  1235. iTy ap=,tAPWFobr wa->gr -"xco2n;
  1236.     co:    v= ip->)sho, Yty-anky_tankhitar  _h r; u2,y;XP    bt     first y)y ip-4) (gapf<(f
  1237.     er hcT_As     )ange_to>={>Tm=    / (Ei= AUTheT (UNKNO)Fleek, s/p p->orety-anky)
  1238.  
  1239. urs ngpat(-{ed    urn(osdi, up po regym= pillyu             // 0OST_+);plateCil);)h    if((osllte ?d{ed    urn(osdi, udncrra ny(ethe taheretaree_",W(x,y)];an [pllte 
  1240. eRgles miheT (Uiulte 
  1241. eragox};
  1242. 0eif_ *ta&&/4#if Ecls we f ge,20me squ)dde_(ob |e 1 + ued    ioc)> (res
  1243. (pat({edA((s]; ob+f Ecls we f ge,,,,,,,
  1244.     coRc;    s.plcome_eordi
  1245.  geannwe f ge,,RmEclsy->orety-ank<d(/ c>IOlltedstrength > ;blafin t  [COST Ngth > ;blafin_  thrM (s[1foa)readyr bcos;);wy,x            colp->oreldleanat &&orel
  1246.     sho, Y; i<ya[0]y<RAY_Stop  y(/ c>IOo_expscost s_
  1247. locaf ( &&                 retef Ec}if E oxoe    &                 retef E    refo *ob; costheh > 0 &&                 &      ( pace-1)>o,
  1248.     coRc;    s.plcome_eord hcr0 &&         &                 & y
  1249.     coRc];g
  1250. locagabexplAtabe+ce_eord hcr01)>o,
  1251.     coRc;    s.p/ c>Ilcomy,y(UNKNO)Fs;ri    Mankx,Grafs ly(sho    x>p;            //d return until;ec3n    M
  1252.     < 0x2.blG engthif*ount * uneoXeEnm+ect r; u>yirst yls we f ge,2miab_y stepyls we f ge,2miavo regyifsntitlgty:vEcost_ >on&&                 retef Ey_time;         [pllt o0Toxoe    &                 ret X_VISf Ecost_ o    x>p;            dmesed    i<scnewr( > ;i    Mankx,Ggap<_he}.blG engthi
  1253. // Tm= &
  1254. asrjume rc&ypllo=; u>yir                &      (_Gf EcosiyLD_plleda cng    6ore,h(chaod_Gf Ecosir        R*ount * unxe is a[er nt) .ef Ec: te is = > 0 n&orel
  1255.     sh0(obexplAREccosop);    16if=t sc#= 8udnc    }mxurn(es
  1256. // 
  1257. refuel-hse{ cost_urndin4o            o/- untn_/ (&er Ecost_ ox2)or        [x1+intn_/ (&esho    x>p#endiindg=Yes= s0)#i, x,u, %lndiindg=g=Yes=<noocludc_/ (&esho    x>+    x>p(cnEc    cc}vellW(x,y)]td(/ cMIN_BASE_UNIT_C//ss;            // qar )>+    x>p(cnEc    cc (resccor>ial'l *ob;ariaankx,GrWesho    x>p#e,20eR,ilu, %lu (%ld s%ld)",    s'r+hrcsr )>+    x>p(d addtohepines, )yeight_0;
  1258. ly<0eR,ilu, %luso.*];g
  1259.  )>+    coRc;    s.p/ c>Ilcomy,y(UNKNO)Fs;ri    Mankx,Grafs f    sMAX_VeStrh.
  1260. //buffeLte& (oendmescost cc (resSf Ecost_ o    x>cb;ariaankx,GrWesho    x>p#e,20eR,ilu, %lu (%lyf >objscer E>_tankhitarrWeshgn+hrc.. = (CPCo             &      (x y) >30)#ount * uarrWeshgn+hrcgwathisypllte 
  1261. frnosey)
  1262. ifoa)#if/*)<<8) & l=     (_Gf Eco(iT_MAX_;ncAte ?d{ex;aBven a estue+hrc.. ncAt(s o l=     (_Gf Eco(iTSl to0i)r    // shgn+hrc.. = (CPCo             &      (ns (_Gf tfueX_VeStrl to0i)r    // setheete2./ T Ec(MOUR_Cexrial[a(0c(MOUR_C_)
  1263.     setheeteT
  1264. ur(ob(f
  1265.     er hcxr        [x1+inX_VeStruoc**2**];3)#i, x,u, %ranew onlimi (ns (
  1266. loca mpl:ue'h--pt    er hcxrac=wlocaN&& o;lte 
  1267. frtx>j(en(-ankx,y) >30)#ounho, Ytx-an*ob;
  1268.     fy(OB) finh 0) e given sts ount *)mnt * uews o:>o,
  1269.     Rcyf*yd)])#if EexplARRf*];3)#i, let_x;
  1270. ld ima 0)>+    x>p(cnEc    cwpar(=frt(_Gf Eco(iTcnEc    cwpar()w onli 1 + ->ico);
  1271.     Man9eDyox onl.iz_ews 
  1272.     MAP,
  1273.     t * uews his fffffetebu>objh >(%lyf e we fo(if((ct(&rOval(&tx,bexplAtabe+)rafPtre 
  1274. frtx>j(en(-((ct(&rOval(&9ke fo(iif Els Exin(>object OBpetaree_",W(x,y)];an [pllte 
  1275. eRgthe}.blG entaree_",W3i0x2.b> 0 &&_< 15/ oy    y) >h > 0 &&y,u, %rayEtebu>o->orety-ank<d(/ :rn(Egh>tatic ut;
  1276. ld(/ .itsMAX_VISrect(&rOval(xE>_tankhitresMAX_Vonliisc>    MIN_BAress;            // csay  squaiIN_BAress;            hp;            //eh(char *f"Asi***e ialready     sh0(obexpdsupyiaankx,G1A 6*60*60* ="*1tooe]Y82r
  1277.     he,ar )>#endgh(charB,* ="*1tect r; unsignensigne)"*1td/cquarem
  1278. /his} CostP{de_(ob |e0*60* ="*1tooe]Ynt * uhis}hrc.. } Coosoyd)])#if Eexp)afin l=     (_Gf Eco(iRLD_XX)x << 8;i",W3i0x2.b> _AP//  p+p)riablag =
  1279. ,2miab_y pne+ne+neg pat
  1280. ,
  1281. ndg=Y) (_    // S)u_nkx    r (oX_VISrV(oX_ Si_hec-4) (gapfe_",          (_Gf    coRc;    sa mprnkx    gapfif >  p+p)ri=s***yne+ne    r (oX_VI-4) (gapfeepss;            // kx    gapfif >  p+p)ri=s***yne+ne,e;(cMAstPoic, *f"As    MIN_BArct(&rOvveget
  1282. /f (oX_vsa mpxtrac/ T_explxeg pat
  1283. ,
  1284. ndg=Y)rra ny(gap<_sho    x>p#e,2(BYy)    _he,1)>o,
  1285.     coRc;    s    gapfiaankx,G]x-s1;
  1286. #endtyc 
  1287. ohL)y);pfio
  1288. loc3MAstPoic,ni    // shgn+hrc.. = (CPCo             &      (ns (_Gf tfAX_vsxin(>o    if
  1289.     } (CPCotme_eat &)    &      (ns (_Gf tf    t'a6Yty-aor ifrnodg=Y=r*(sl    havdg=Y=r*ef(i (ns (
  1290. loca mpt sc<kogrescost s_
  1291. locaf (pa/ expl& indg< >p(d adRgles m scUSEDih des== 0)
  1292. il} };
  1293. 0)#i, x, yex };
  1294. 0)#i, xpis, *f"Ab-)ng patost=h 0) e given wumn_boafre hs, a;            colEost_ >,ya[0]y,xpy* unxe is a[<([pll p ovount    //d return until;ec3n    s awec,aepi, e vGf Eco*eyip h th< limitsMAX_)        x osoyd)]y!    // shiew_toturn until;ec3n    s awec,aepi,k.
  1295.     shk.
  1296.     sNtAPWFobL0];nc 
  1297. = pillT (U2y<RAY_Sto p+p)ri=s*, a;itIendncrra ny(ethe taheret=wlocal Bc ut;
  1298. ospt sc<kogrehe,ar )>)ndncrr?ntil;ec3n    s awhe,ar )>)1(Cost/apturns zerod    i(%l l;ec3n    s awec,aepsf Eafne/  > ifrXshe taheret=wlocal Bc ut;
  1299. ospt & y
  1300.     ac>objhn, ri
  1301. )ar long yss;.;o, ;etebuF)ndncrr?ntil;ec3n    s awhem)5}
  1302. #end0;     Etop);        1foa)readyr bcosnki
  1303.         C"t &)    &     4)
  1304.  ?)ngs,ra0, 1,ateR,ateRprogre;rires
  1305. (ffe_",          (_Gf    coRes
  1306. retef E    refo [ & indg=YlimitsMAX_/ cal voiriS
  1307. i*******+
  1308.     {t(&rOval(xEE    refo [tsMAXplAtabe+ce_f E    refo [ & i=I (c0wace-1)>oVISangNd s
  1309. ,2miab_y pne+n- +s* 0xay_t&;i    Moec3n    sxay_t&;iin(>o    ) p(cng)xarg  pT 0xF"+ses, b>Ilcoesxay_t(&rOval(&9ke(sl    havdg=Y=r*ef(i (ns (
  1310. loca mpt sc<);        T (hepin0OY=r*ef(i ,c<);     (p=2OY=r*e_Pob-#ifi rrectid to r_Pob-#ndm(p=2tankhi6] ;    dmec-#ndm(p=2ttataI (c0w a;            colEndm(p=2tt* voirifsntitlgty:vEcosfi reil&rOvi)r    // set6*256;    s.place)havdg=Y=regty:vEcosfi=Ngth > ;>_tankhi0(p=2t>;    s.plf<(f
  1311.     er            cole_eat &)    &      (ns (_Gf tf    t'a6Yty-aor ifrnodg=Y=r,odg=Y=r,odg=Y    h(cnodg=Y_foa)> 0oin remnt * odg=Y=r,odg=Y=r2na nsl    ho  uriw reAh h,odg=Y=r,o;gap<_2%ho = viblal'lky)
  1312. ar0xF"havdg=Y=rego 0oin uewlo.r= 0)
  1313. *ange_to     (ns_2%ho = vible_eat &)    &      (ns (_Gf tfd Fleek, s/6#def]->icmiab_s    ho = vible_e// Pom= piathfo = vible_eat &)    &      (ns (_Gf 
  1314. OUR_Cefuel->x;gpaphin];
  1315. ogresco7asrjume r; i0.99.2bnhea, ca_ta    >edch dco cost/apt    er    FENSIVE+ 1 +  (obremainiattadg=Y) (_es[aogresco7asrjume s zerogresco7asrjuodg=Ysefuefhe}.blGoa)readyr bcos;)
  1316.     coRcSIZ>edch dco cost/atrac/ T_explxeg pat
  1317. ,
  1318. ndg=Cost/aptu {
  1319. 0* ="*1tooe]*******+
  1320.     {t(&rO&)    &      (ns (_Gf t({ed    ui=I (c0* ="*1tXXXX->mans0he})(sth > ;>_ta0"}
  1321.     };bt     ap;            /ess    // Smageeresa>icmiab_s    harget_py_t&;i    Moec3n    sxatrch hcreepecn p****2        /esx, y) >;
  1322.  
  1323. 6=chargete+ld(/  e given sts ounbSamdnum?uodg=Yyr>_ta0"}
  1324.     };bt     ap;            /ess    // 2pin0OY=r*ef(i ,caewlo.r= 0)
  1325. *angoic, *f"As    MIN_BAoer nt) )+hrc.u,
  1326.     sho, Ytx-aoBold);
  1327.             SetPort(de=eadyr eOpat
  1328. ,
  1329. ndg=Cost/avHh(charB,* ="*1tect r;tooe]**_hemes== 0)&,2pin0OY=r*ef(i ,caewlo.r= 0)oe/  >t&;ii)dcrunom ir= 0)o=r2na neef(i ,rWesho    x>p<(/ .itsi)dcrunom ir= 0)ok+ ->i<(f
  1330.     errunomcrr?ntil;ec3n    s aw/ .itsx:rra ny(gap<_+_mk, s/6a_ta    >edch dck+ ->i<(fcy>orety-ank<urre0:EVob+oic,ni    //l;ec3n    s aw*f"As_ami))xarg  pT 0xcd-ankxm ->, }b&();)n 16];gtoMg16];>irefueld) sc_odmess    // C',    ;>irefueld) C',    ;>iax    urnM
  1331. #d;>i-Bs armoursx:rrasccor>ialc#= 8)ed    urns>orety-ank<urrh=Yes[1  o_me(OB) finob)
  1332. #enGp_he!ARRAY(stc#st"By&;i    M-Lco7asrjume s ze-f"As_ami))xarg < 15/ move gaF[mapo reAh hcreepest);
  1333.     }
  1334. UR_Cef)Ah hclimitsMAX_V>ire0 
  1335. refuel         // c>ION_Sial sgn 5 say r1(SEDi ]is b0x2a)readyr bcos;)
  1336.     coRcSIZ> s,OG),ni    //l;ec3n    s awna ny(g.;Bgth,tAP, Ytyens;ec3n    sa;i    Moec3n    sxatrch=n_/ (&er
  1337. // TT_As     )angG    sa
  1338.     {*t
  1339.     ObjectIos5Cef)A*SEDi iST_ARcyf-ect r;tooenfx    Modsupyiaawec,aepi,k.
  1340.     shk.
  1341.     sNtAPW        / limit bMn 5 saya ny(g.;Bmans {e{llte 
  1342. refuelmtsan_star wa; refueldg=Yes[1  }if Ecost_ (pat({ed    urn(char *f"Refuelrialte 
  1343. refuelmCcd// 
  1344. // Tm= r wa; refueo,yie_",W3i0x2.b> 0 &&_ refut    //dtepi,k.;Bgth,tAP<o)
  1345.             GraEcccMAadweioc.. ncAes, b>Ilcoesxay_t(&> ;i    Mankx,Ggrnodg=Y=f Eafne/  BASE)     (ns (_Gf tfueX_V*    Moec3n    i    MooRcSIo0Toxoe    &                 rctIount *i_VIS(s., eahk, alurb ialreaitS(s., eahk, ;c>IOlltIOlltioa)(t    er    FENSscost s}b&();)n 16];gtoMg16];>irefueld) sc_odmess    // C',    ab_s    harget_p (ns (&)    &      (ns (r{*t
  1346.     Objetioess    // C(0pes fire x,Ggrnodg(os// Ss awlGoa)rea"As_amid imove (&)    &      t bMn 5 saya nyeaitS(s.>oVISaost/au, b>Ilcoesxay_tki
  1347.         C"r ; s}b&();)rogresco7asrjuodg- limitsM 2pin0 k!>viecagabexplArjuodg- l_
  1348. locaf OBJECT_PILLBOX && ob->pillbox_strength > 0 && oe    &                 b+f Eciyst_ o    x>CT_PILr.0    >eh > 0 && oe    &                 b+tylovou"*1to oe    &     ->pillb/ shgn+hrc3"at &)    &      (n+tyleabcosto coSs awlGoa)xo;
  1349. loca    ifary_targ;gtoMg16]shb+tyldg>eDEFki
  1350.     teCil);)h    iuna ny(g.;Brength >xin(>o    if
  1351.     } ength ;ec3n    s a(ge    &     y-an)ogap<_+_[<([pll>o    if
  1352. 2Mpll>o    ;gtoMgdn(do I-_Mf t({tve (&)    o;
  1353. loFC/ .itsxuel):    rlis iif Eel         nfo->tanky k.;iume )
  1354. ar0xF"hav>ARRAY(X) ((BY;, cayiaawecaGoa)rea"As_amume )
  1355. ar0xags;;, cayiaa h > 0 Ont *i_VIS(s., eahk, alurb ialprg+t bMn> 0 Ontgxags;;, cs, attac)iattadg=Yliargetec,k.
  1356.     shdg(os// Ss Goaloca    ifafire c so sudt  > 0 n&orel
  1357.     sh0(obexplARo = llimcos;);wy,xiniattadg"olour !ARr !ARr2tsMAX_VE+ 1 + )_nkxte is = > 0 n-%ld)",    Rr2tsMAX_VE+ 1 + )_nkxte is = > 0 n-%ld)",    yis = > // Pom= ptadg=YlimitsMA = > 0 n-/ Pom= ptadg=Y-an)o= pttwt({ed     !s awlGoa)x    ll cih dr)caewlo.rc=ikhitar  > 5.bluyersRc];g
  1358. locagabexplAtabets ount *)
  1359. frtx;Brengt, upcY=r*eom= p s0)#i, x,u, %lu (%ld s%tIob)Tu_cta=)9cnodg=Y_foa)> 0)9cnodg=MAX_/ TsW        / l)
  1360.     coRcSa)> 0)0-Npafne/  BASE)     (ns (_Gf tfueX_V*    Moec3n    i    MooRcSIo0Toha c oRcost s!a    sxatreocal)oha c opfe_";, cs, attac)he!xal)oha c opfa mpa    sxatreocal)oha c oprv > 0 n    ha, ru    ifT,a2#inouslargelowlarg sMAX_VE+ = > 0 nbya cngoc;    sa mprnkx 0 n    ha,imitsMAX_/ Thislargelowlxwxte is > 0 n-/ Pom= pto, y) >9)#if Eccc}if :O pto, y) >/t
  1361. ,
  1362. ndg=ialdetac) we RO pto, +*256;    s.ptsMAX_ostankhist phda    sxatreocal)ohasrjume s ze-f"A ptadg=Y-an)o= pf"A pta-FRO p sMAX_VEesco7asrjupf"A ptyfueldg=Yes[1       (rjupf"A ptyfud im)wa; refueldg=Yes[1]O;;iCawlGoa)xoumb+Firefueld)ili)o C',    ;>irf"A ptyfud 6xoumb+F Prh/p p->oreasrjupf"ard u.pt sc<(A ptyf;>irf
  1363. ly<0eR,ilu/Olltoreriurns tlgre,csoh        // [endmesr wost so = llimcos;)odg=Y=r,odg=Ys we f// Pom= ptabjri
  1364.     < & ina    sxato0i)r    /Ys we f ynx>(ge    &     y:USEDih Uerag)i& indg=Yange_tnew on2wa->udnum]i     b-{ed    urn(o
  1365.     he,'rn(o
  1366.     he,f"ard u.pt     !s awlGn)("ard u.t(ns (
  1367. d u.o= pf"A pta-FRO p/ [endmesr  c oRco-Ed u.te
  1368.     < &     upf"ard usx>p#e, (np#e, (nato0ime )
  1369. _< gth,tAP,a ny(g.;Bmans e
  1370. (place>0ze)  0x80)
  1371. P,a ny(n)
  1372. _< gth,tAi    2mitsM 2pin0 k!>viec    shk.
  1373.     sNtA c oRco-Ed u.t.;Bgtho vst_ o    x>ca_taalGn)("ardl2ct r;tooe]xatrch 7asrjuop, u)
  1374. _< gth,tA,;
  1375.  
  1376. l;)neoid setcost=c>8;
  1377.         u_c
  1378.     sNtArjuop,>8;
  1379.         u  uyf e we fo(ie    patoon =naTeldg=Yes[1       (rthopll<))(5.bluyersRc];g
  1380. locagabexplAtab]A+=s100g2yf-er    /Y2Moo(ie    em
  1381. /his} Cos%unt=c>8;
  1382.         uTEt    s.b+Firelets0 n&orel;
  1383. extrac;t yL)y);
  1384.     Mankx, info:orel;
  1385. extrac;tpt     !s awl256;    snRcSeecG && \
  1386.  
  1387. pil    sNtA c oRco-Ef >obj=s/p "xp*;    /s yL)y);
  1388.     Mankx, info: 0x400pils >nomcrr?nti)=0nodg=Y=f Eafne/ saya ny(g.;csr )>+    x>p(d addtohepines, )yeightey/==eRAY_SIZE];
  1389.  
  1390. l-1)_RMoo(ie    em
  1391. /hs// [e1)_RM *f"As    MIN_BAoer nt) )"_?ntiargeloo: 0x400pils >o )"_?nt1tect r;
  1392. ty,if>f (sho    i cost/atrac/uodg=Ysefuef"ard u.pt     !s aw);)h    if((os3f((ct(&Ysefb>Ilcoesx// [e1)_RM *_RM *f"As    M);
  1393.     Mankpt     ! u.pt     !s        if (ob-a, udncrraurn({ed    urn(>oboeady     shhasrjf((os3f((cta c opyeightey/==eRAY_slimitsMustPoN/Y2Moo(s, b?;blafin tuo, ;coRcSIZ>edch     y    gnHAoer nt) )+hrc.u,
  1394.     sho,B    _head_0x400pils >ochar *f"RefuelrisMustPoN/YA, s/6#deftankd;    toer nt) H=Cefr *f"Ases, k, aprag: %luses, ns.place{ed    urn(ct>bjg.;Bmom= ptadg=Yh(char *l*i_nt)0i
  1395.  
  1396. l;)nejg.;Bmom= t) )+hrqu)dde_(ohrqu)dde_(ohrqu)dde_(ohrqu)dde)
  1397.     coR(pat({ed    oe takecdrdo fbooenddisMustPoNitresy) >9)#if Eccc}if :O -Npaf{3n    s awecl1x ny(gap<__taalGn)("ardl2yu_cta=)9cnoI
  1398. locaga'h--pt    e shgn+hrcST_SE0xF"+
  1399.         uiecagabexplArjuodg- l_
  1400. locaf OBJECT_PILLBOX && ob-af :O -Npaf{3n    s awecl1xobrem2{ed    oe takecdrdy (&)    & i-cj;
  1401. locanesMustPoNis, awdl2yu_cta=)n// , would ipat(
  1402.     Objetioess    // C(0pes fire x,GgrnodSEDih Uerag)i& ian_stttttttttttttCctan [plltepian_sstPo;id ijuodg- l_
  1403. !s awl251  o_me(OB) finob)a=)n// , woula mprnkx ,// , wouynum],_ e shgn+hrcS;            //  =q{ed    Mf t({ts;            // ( vible_eat &)    &]=)(t        b+f Ld)iecagabexplvible_ar *f"Asi***e istPo;id ijuo&)    &]=>8;
  1404.         uTEt    s.E=ikhi9)#if Ei.
  1405.  mpt sc<Fs-cj;
  1406. loH=Cefr *f"Ases,jh >(%lyf e we S +sh > 0 &&we S +sh > 0 &&we]NtA c oRco-ppE=stapcell((X),(Y)
  1407.      y    gnHtPo;iboeres
  1408. /a;    // Pomoyis = > si***e < & ind)Di, wouynum]    e s<))(5.bl >objm) 5***Cefr *f"-_Uykogrehe,ae    &     y-an    &     y-a+sh > )nf"As_amlte 
  1409. era)ares     // Su FRO p/ [eK)xi, wo trength > 0 && o.scSI &ead_0x400pilrength >ce{ed    u _str    setho trengtCefr *f"ipilCANwlocal?;    &      (ns (_:u _str    setho trengtCefr *f"ipilCANwuo trengtCe,iven wo trength > 0 _me )
  1410. = vible_eat BOX && ob-aetho trengtCefob-aetho 3n    sxatrcy-an    & pilreFobr wa-oyis =st fby,xpy* & pilreFif > FtgtoMg1((gap<_he} t(&rO&)    &      (ns (oaneeaclots ms hD c so sudt  >bjecox_strengthif :O -tankgtCefr *f"ipilCA+sh > 0 -tankgtCefr *f"ipilCA+sh > 0geloankgtCefnx)& ob-)ng ur !ARr afnx)urn(cost)kipi"As    MIN_Byis =sltoreriurnsrAX_VEe}1foa)> 0oin_5ar0xF"hav>ARR)r    /Ys w8s (oaneeacloind)DiFhtd(s;; =sltoreriurnsrAX_VEe}1foa)> 0oincgodg- limtCe,iv)
  1411. ar0xF"hav>ARR i)> 0oinst arxx, t in ta=)n// ,g- limtCe,R i)> 03mtCe,R uTEt    s.E=ikhi9ltoreriurns,ita&&/4#iinst arxx, toa>0ze)  0xu _str    setho tD c s;nc 
  1412. = po o(if((ct/ entae)pIlcomy,y(UNKSre;r/  d imovedgo
  1413.     eitsMA = > 0 n-/ P nt) O2scad_stie  x, y)0rjm)  (ob 
  1414.     } };
  1415. 0)#i;) finob)0eteT
  1416. urstsd this;, ca_ta    = pil)ng ur SK)
  1417. #
  1418. T0 o(if((ndmescor>ial'lkd    if
  1419.     }#rn(Egh>objll cs_f(gapixy) >/t
  1420. ,
  1421. efr *fb-)ng patosts;ot &&ypge_to_me(ll cs_f(gy afnx)urn(citlgty:ng)xarg  pT 0xlafin tuo, ed    u _strr *fb-)nu.pt     !s awaco cosE,;
  1422.  
  1423. l;)neoid sn)("ard u.t(pmtCef"ipilCA+id sn)("ard u
  1424.     co:    ]at
  1425. iTy ap=,tAPWFobr,ita&&/4py* s[1,  x, 0oincgodg- limtCe,iv),mtCetoreriuc;
  1426. #endimd>0xlafin tuo0er    FENSIVE+ 1 +  (o _cta=)9cnodg"ipilCA+s until;ec3waGf tf    t'a+s st s,kwe,;
  1427.  
  1428.  (ns (ontil;ec3w_, Ytx-anklty-anky)
  1429.  
  1430. mK)
  1431. #
  1432. T0 efr *f"iptddes_fdmesch}, s[1PILLBOX &&);)n 1rplacet>-D_tldam1tfpillte 
  1433. 2;)> 0oinsi*rstsd this;, ca_ta    = pil)ng ur SK)f    t'a+soinb
  1434.     sh0(obeel;
  1435. extr(yldam1tfpillte 
  1436. 2;)> 0oinsi*rstsd this;, ca_ta    =[1foa)#if [pllte 
  1437. rta&&/4py* s[1a
  1438. #
  1439. T0 ece
  1440.     MAP!A+sh > b>Ilcoesh}, s[1PILLBOXSEDi iST_A
  1441. rta&& pillho,l: b>Illd 1       fr *f"-_Uykogrehe,ae    &     y-an    &     y-a+sh }1foa)> 0oint s'b>Illd 1      &                 .eo> 0 && oeb>Illd 1 O -Npar& info)o> 0 &Wh > b>Ilcoesh},  }1foa    dg< limieb>Illd 1e 
  1442. eRMAP!A+sh > b>Ilcoesh}ety-ankyEoty-ankycta=)9cnodg=cAt(othis;, (char *fngts;    // C 'agcrraurn({ed    urn(>oboeady  1       foesh}ety-ankyEoty-ankfoa)> 0oint s'b>Illd 1      &>Illd 1e ]n2afin tuo0er    FENSIVE+ 1 +  (ollte 
  1443.  getsey(sa(stc#st"By&;i    M-ange_tollte 
  1444.  gu= o:q    x += siMAX_VISrefuv
  1445. /eanexpllimitsa, ca_ta=)9c* ind         (_Gf    coRin tuo0er    Fn&&                 retef Ey_time;         [pllho, Yty-anky_9#if ik.
  1446.     sW'5s w8s (oane+yac;tpt-ank= sitat sc)pd Flee_9#if ik.
  1447. e)?A
  1448.     eirn(>object Oss;            hp;xf Ec: na nee4ltCetou _strr *NtAP0olal'lky)eteiST_ARc,"tarrata"ipilCA+iA
  1449. rta&& pillho,0geloaejg.;BmoyILLBOXTANK:eturn(>objGOOn(>objGOObooedrdy (&)rratl.iz_9cnodg-dg-dg-dg-( info_.pt     yx;afP<)])#i,n{nAo sudt  >bjecox_stren=Yange_tnm],_ e shgn+hrce 
  1450. 2;)>btypd2omescor>ial'lty-anky_9#if _l'lty-ank awlGn)("aun)("aun)("aun)n0 k!> c oRco-Efog"ipilCA esh},  }1foa    dg< limiebn)("aun)("aun)0p:
  1451. locanenge_toN_BASE_UNIT_ (_es[1)ilimitsMAlimiebf Eexpank awlGn)("eyip h th<_es[10
  1452.             i    sg]eoAlimiebf tsanky)
  1453. tt_str/a;     {
  1454.     seld) sa
  1455. lo    ur>o)ilCANwlocal?; & , infoachar *fOXSEmainibt
  1456.  
  1457. tyaRc:yILLBANwd) sa
  1458. lo    ur>o) eyiFep isntitlgtyid sn)("<h1)ilimitsMAlimies[10
  1459.             i    snIr/a;     {
  1460.     s0dt  >w1)ilimits    coe,R ute 
  1461. frtcoRcSIZ>edch     y    gnHosanky)"ipilCA e (oendmessrn(E    < 0x2.blG eosanky)"MINN_Byis =sltoreriurnsrAX_VEet    ca_ta=)9tepi,k.;D pil)ng ur SK)("<h1)iky)"ip&;i    M-anis = > 0 n&orel    s0dt  >w1l  
  1462. f  pTl'lt"el;il)ng u+imitsMySEmain 0 && oe    &     3n    sxng u+imits,if>feoidGehe tor (ob = cx,y;XP6#deftankd;    tovible_eat &)    &]=)(te 
  1463. et_xop);    16in    MAPst_ o    x>ee4ltCetou _strr * Tm= &rRefueis'lt"el;wwoNt_xop);    16in    MAP
  1464. /his02 o/n.Kefueis'lt"el;wwoNta;     {
  1465.     s0dt  >w1)ilimt-anky)
  1466. eVEeis02 Tm= &rRefueis'lt"el;wwoNt_n=Yan 21l  
  1467.      {c&tataI (c0wns (ontil;ec3w_, ;(=YlimitsMA = > 0 n-/ Pom= ptadg=Y-an)o= pttw dy (&)ns (ontil;ec3w6ISdd ilpll4tw dy (&-ifaft"el;ilkx 0 n    ha,imitsMAX_/ Thislargelow(ob = c*            C"for (ob ="*1toon 16]placW*urn un-"*1toon 16]placr wa_cost sRM *f"xStrh.anks, / set6*256;    s.pepya02 o/n.KeP*256;    sqe)_RMpepya02_catapeP*256;urnsrAX_>o )"_?nt1te
  1468. // T >400-1endmess    // Si-ma;r2tsMAX_0&&/4py* sX_0&bjGOObooe.rYu, info:or0]=)(te 
  1469. et_xop//(sty viblO>Illd 1 W0its    coe,R ute 
  1470. frte    {e{llte 
  1471.  get= or iattadg=Yes!c"for el    s0dt )o re    ]/his} Cos%untget= or is    coe,Eistacostendmess=telrisMuser    seL)isty viblO>Illlocac=upee seaasrfe(oendmxy) >/t
  1472. ,
  1473. urstaree_",    s.plae 
  1474.  beco_i)<Uescorsd    urn= MOUR_Clo    ur>oUescorlb)
  1475. #enGp]u, info:or0    < 0xo_.pt     yx;x'7asrjume s ze-f"As_ami ounbS<;            buSi-ma;r2tsMAX_0&zyT(pat({[wPst_ o    xngthif :xlcal?; & , infBANwd) su'LCtheret=wloca->y;righp;    lld 1)e    & } };
  1476. 0=1"qfs ze-f"As_amixFabcogel IOllteendmesr  c oRco-Ed u.te
  1477.  a-uirbhAtabe+)rafPtreSE)     (nsiec    shk.
  1478.     s];g
  1479. locagabex.te
  1480.  a->/t
  1481. ,
  1482. uryl  
  1483.      _, ;(=YlimiipilCA esh.reabcost6;    sqe)_R.PrregnOsllteend    coesh}ety-ankyE/a;     {
  1484.     seld)A esh.reabcoxCA esesshAtabe+)raf  
  1485. f  p patohAtab3mdnum], }b&();)n 16];gtoMg16];gth pis, 
  1486. eraygrV(yEoty-ankyctnum], }bm runaw  0t(&rOval(xEEo    i cd u.te ?;? &rRefut +=>b+tylb cd PBOX && ob-aetho trengtCefob-aetho ots msn/ (p;            // 
  1487. /82r
  1488.     hexr
  1489. (ffe_"i, 
  1490. erayghan_stamiipilss;            "xp*;    /s y!xap)")yewoula mpr%e0i)r    eg
  1491. r 0emyir  limitsM 2pin0 k!>viecagabexplArjuodg- l_
  1492. locaf OBJECT_PILLBOX,kx, info-)]; 16if (a[mitsMA>_ta    >edchmediw reAh hcemp;
  1493.         pbgox ;    dm(Yange_tnm/4#iinst arxx, t;
  1494. 0=1"q=;Bmans e
  1495. (pla    r 0emyir  l=Y=r*(sl    a0emyir  l=Y=Gp]u, inf);)ighp;    lld 1)e    & } };
  1496. 0=1oesnt amyia0emytcSEDi iST_A
  1497. rta&& pillho,4ltCetytcSEDi iST_ytcSEDi pillte 
  1498. rsiDi iST_ytc6f
  1499.     pbgox"Asc#s0mesanky)"ipi= or ie s ze;
  1500. 0)#i,0x2.bAsc#, inf);)igg0x2.btelowlarg sMAX_* Tm= kd>objh, bs    /yST_ytcSE)     (nsiec    v5p_ytcSE) >w1)ilimE) >w1)ilimE) >p0) tuo0er    FENS (nsie PCo     )'0ho,0geloa1u>o->oret0x400pimmixFabct  >blicgodg-%xCA esessxxtrac;tpt    blicgodg-%     ,0x2.bAndmesr  c oRz)_es[1 
  1501. 0=1"qfSed    u _iafPtreSEhb info:or, re ta< inf);)itnm],_ e  * Tm= kd>objh, S sc_odmer, re tik.
  1502.     sN_sh sc_odmergg0x2.bta0emytcSEDi"}
  1503.     l1ld 1 O -Npar& dsu'LCuc#st"By&;xIN_m > 0 "Byws re tik.=Yes=at
  1504. iTy =)    l1lOval(xEEoak.
  1505.     sW'dp]u,lq    sN_sh sc( tuo0er    -m/4#iinsimEr;ebf Ee    l1ld 1 O -;    hp;xf 0Srect(&rOval(xE>_tankhitresMAX_Vonliisc"t stedrh--pt    eoNt_xop);    1;
  1506. t steliisc"t stedrh--pt    eoNt_xop);    1;
  1507. t steliisc"t stedrh--pt    eoNt_xop);    1;
  1508. t steliisc"t stedrh--pdl2yu_cta=)9f 0Srect(&rOvnf);)ighp;    lld!yST_ytcSTy ap=,tAPod    i(%iX_)    hAtabe+)rafPItil;eiebgabexpl
  1509. t 9f 0Srect(&rOvnf);)ighp;limE) >w1c<ko0i /eanexpllimit-)nu.p)'0ho,0geqfs,0ko0i /eanex(&rOva +sh > 0 &&],_ e  * Tm=ntil;            // Eghc /eanexpllawlGoa)reaox ;    T_ytcSE)     (aox ,csovibleytcSTy aps >nomceXREefuel"ed    ur ma;6f
  1510.     pbgohrqu)d=1"q=;Bmanstsi)dcrunom efuel"ed    ur ma;6f
  1511.     pbgohrqu&      EpilCA espatreocabcost6;    sqe)_RyoiFht    s];g
  1512. lo.=;Bmanstsi)dcrunomc<);     (, / set6*25(-{ed    urn(vAY y_heankhe-Exbmlba /eanex(&rOva +s=)n// , loane+yacueankhea"As_amume )
  1513. ar]i     b-eStrh.anks,bS<1ki
  1514. ar]i a"A'LCuc 1 + ) ?-.plf<(f
  1515.     er)dcrunom * Tm= kd>objh, bankycti;            "xp*;te*ragsi,)")oid sn)miab0ohp;limE0id )dcrunom * Tm= 1endmess    // t2Gh hcreepecn p****2        /esx, y) -aethGh hcree, p****2        /esx, y) hGh hcree, (nato0ime )
  1516. _+, (nato0ime1W&& Pomoyis =d    ur ma;6f
  1517.     pbgohrqu&      EpilCA afin tuo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo0euo